diff --git a/IPython/core/display.py b/IPython/core/display.py index 41efbeb..af2b538 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -794,6 +794,7 @@ class Javascript(TextDisplayObject): r += _lib_t2*len(self.lib) return r + # constants for identifying png/jpeg/gif/webp data _PNG = b'\x89PNG\r\n\x1a\n' _JPEG = b'\xff\xd8' @@ -801,12 +802,14 @@ _GIF1 = b"GIF87a" _GIF2 = b"GIF89a" _WEBP = b'WEBP' + def _pngxy(data): """read the (width, height) from a PNG header""" ihdr = data.index(b'IHDR') # next 8 bytes are width/height return struct.unpack('>ii', data[ihdr+4:ihdr+12]) + def _jpegxy(data): """read the (width, height) from a JPEG header""" # adapted from http://www.64lines.com/jpeg-width-height @@ -826,10 +829,12 @@ def _jpegxy(data): h, w = struct.unpack('>HH', data[iSOF+5:iSOF+9]) return w, h + def _gifxy(data): """read the (width, height) from a GIF header""" return struct.unpack('