From 9fc4e1feac096be37903d080d476de1fc8cc8828 2017-07-29 03:13:52 From: Grant Nestor Date: 2017-07-29 03:13:52 Subject: [PATCH] Extract width and height from gif base64 string --- diff --git a/IPython/core/display.py b/IPython/core/display.py index 21fa8bc..1333bff 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -965,8 +965,7 @@ def _pngxy(data): """read the (width, height) from a PNG header""" ihdr = data.index(b'IHDR') # next 8 bytes are width/height - w4h4 = data[ihdr+4:ihdr+12] - return struct.unpack('>ii', w4h4) + return struct.unpack('>ii', data[ihdr+4:ihdr+12]) def _jpegxy(data): """read the (width, height) from a JPEG header""" @@ -984,8 +983,11 @@ def _jpegxy(data): # read another block idx += 2 - h, w = struct.unpack('>HH', data[iSOF+5:iSOF+9]) - return w, h + return struct.unpack('>HH', data[iSOF+5:iSOF+9]) + +def _gifxy(data): + """read the (width, height) from a GIF header""" + return struct.unpack('