Show More
@@ -794,6 +794,7 class Javascript(TextDisplayObject): | |||||
794 | r += _lib_t2*len(self.lib) |
|
794 | r += _lib_t2*len(self.lib) | |
795 | return r |
|
795 | return r | |
796 |
|
796 | |||
|
797 | ||||
797 | # constants for identifying png/jpeg/gif/webp data |
|
798 | # constants for identifying png/jpeg/gif/webp data | |
798 | _PNG = b'\x89PNG\r\n\x1a\n' |
|
799 | _PNG = b'\x89PNG\r\n\x1a\n' | |
799 | _JPEG = b'\xff\xd8' |
|
800 | _JPEG = b'\xff\xd8' | |
@@ -801,12 +802,14 _GIF1 = b"GIF87a" | |||||
801 | _GIF2 = b"GIF89a" |
|
802 | _GIF2 = b"GIF89a" | |
802 | _WEBP = b'WEBP' |
|
803 | _WEBP = b'WEBP' | |
803 |
|
804 | |||
|
805 | ||||
804 | def _pngxy(data): |
|
806 | def _pngxy(data): | |
805 | """read the (width, height) from a PNG header""" |
|
807 | """read the (width, height) from a PNG header""" | |
806 | ihdr = data.index(b'IHDR') |
|
808 | ihdr = data.index(b'IHDR') | |
807 | # next 8 bytes are width/height |
|
809 | # next 8 bytes are width/height | |
808 | return struct.unpack('>ii', data[ihdr+4:ihdr+12]) |
|
810 | return struct.unpack('>ii', data[ihdr+4:ihdr+12]) | |
809 |
|
811 | |||
|
812 | ||||
810 | def _jpegxy(data): |
|
813 | def _jpegxy(data): | |
811 | """read the (width, height) from a JPEG header""" |
|
814 | """read the (width, height) from a JPEG header""" | |
812 | # adapted from http://www.64lines.com/jpeg-width-height |
|
815 | # adapted from http://www.64lines.com/jpeg-width-height | |
@@ -826,10 +829,12 def _jpegxy(data): | |||||
826 | h, w = struct.unpack('>HH', data[iSOF+5:iSOF+9]) |
|
829 | h, w = struct.unpack('>HH', data[iSOF+5:iSOF+9]) | |
827 | return w, h |
|
830 | return w, h | |
828 |
|
831 | |||
|
832 | ||||
829 | def _gifxy(data): |
|
833 | def _gifxy(data): | |
830 | """read the (width, height) from a GIF header""" |
|
834 | """read the (width, height) from a GIF header""" | |
831 | return struct.unpack('<HH', data[6:10]) |
|
835 | return struct.unpack('<HH', data[6:10]) | |
832 |
|
836 | |||
|
837 | ||||
833 | def _webpxy(data): |
|
838 | def _webpxy(data): | |
834 | """read the (width, height) from a WEBP header""" |
|
839 | """read the (width, height) from a WEBP header""" | |
835 | if data[12:16] == b"VP8 ": |
|
840 | if data[12:16] == b"VP8 ": |
General Comments 0
You need to be logged in to leave comments.
Login now