MCPcopy Index your code
hub / github.com/ipython/ipython / _jpegxy

Function _jpegxy

IPython/core/display.py:808–825  ·  view source on GitHub ↗

read the (width, height) from a JPEG header

(data)

Source from the content-addressed store, hash-verified

806
807
808def _jpegxy(data):
809 """read the (width, height) from a JPEG header"""
810 # adapted from http://www.64lines.com/jpeg-width-height
811
812 idx = 4
813 while True:
814 block_size = struct.unpack('>H', data[idx:idx+2])[0]
815 idx = idx + block_size
816 if data[idx:idx+2] == b'\xFF\xC0':
817 # found Start of Frame
818 iSOF = idx
819 break
820 else:
821 # read another block
822 idx += 2
823
824 h, w = struct.unpack('>HH', data[iSOF+5:iSOF+9])
825 return w, h
826
827
828def _gifxy(data):

Callers 1

_retina_shapeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…