File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -794,19 +794,22 @@ def _repr_javascript_(self):
794794 r += _lib_t2 * len (self .lib )
795795 return r
796796
797+
797798# constants for identifying png/jpeg/gif/webp data
798799_PNG = b'\x89 PNG\r \n \x1a \n '
799800_JPEG = b'\xff \xd8 '
800801_GIF1 = b"GIF87a"
801802_GIF2 = b"GIF89a"
802803_WEBP = b'WEBP'
803804
805+
804806def _pngxy (data ):
805807 """read the (width, height) from a PNG header"""
806808 ihdr = data .index (b'IHDR' )
807809 # next 8 bytes are width/height
808810 return struct .unpack ('>ii' , data [ihdr + 4 :ihdr + 12 ])
809811
812+
810813def _jpegxy (data ):
811814 """read the (width, height) from a JPEG header"""
812815 # adapted from http://www.64lines.com/jpeg-width-height
@@ -826,10 +829,12 @@ def _jpegxy(data):
826829 h , w = struct .unpack ('>HH' , data [iSOF + 5 :iSOF + 9 ])
827830 return w , h
828831
832+
829833def _gifxy (data ):
830834 """read the (width, height) from a GIF header"""
831835 return struct .unpack ('<HH' , data [6 :10 ])
832836
837+
833838def _webpxy (data ):
834839 """read the (width, height) from a WEBP header"""
835840 if data [12 :16 ] == b"VP8 " :
You can’t perform that action at this time.
0 commit comments