##// END OF EJS Templates
CLN: core/display: reformat per darker
Wes Turner -
Show More
@@ -798,8 +798,8 b' class Javascript(TextDisplayObject):'
798 798 # constants for identifying png/jpeg/gif/webp data
799 799 _PNG = b'\x89PNG\r\n\x1a\n'
800 800 _JPEG = b'\xff\xd8'
801 _GIF1 = b"GIF87a"
802 _GIF2 = b"GIF89a"
801 _GIF1 = b'GIF87a'
802 _GIF2 = b'GIF89a'
803 803 _WEBP = b'WEBP'
804 804
805 805
@@ -838,16 +838,18 b' def _gifxy(data):'
838 838 def _webpxy(data):
839 839 """read the (width, height) from a WEBP header"""
840 840 if data[12:16] == b"VP8 ":
841 width, height = struct.unpack('<HH', data[24:30])
842 width = (width & 0x3fff)
843 height = (height & 0x3fff)
841 width, height = struct.unpack("<HH", data[24:30])
842 width = width & 0x3FFF
843 height = height & 0x3FFF
844 844 return (width, height)
845 845 elif data[12:16] == b"VP8L":
846 size_info = struct.unpack('<I', data[21:25])[0]
846 size_info = struct.unpack("<I", data[21:25])[0]
847 847 width = 1 + ((size_info & 0x3F) << 8) | (size_info >> 24)
848 height = 1 + ((((size_info >> 8) & 0xF) << 10) |
849 (((size_info >> 14) & 0x3FC) << 2) |
850 ((size_info >> 22) & 0x3))
848 height = 1 + (
849 (((size_info >> 8) & 0xF) << 10)
850 | (((size_info >> 14) & 0x3FC) << 2)
851 | ((size_info >> 22) & 0x3)
852 )
851 853 return (width, height)
852 854 else:
853 855 raise ValueError("Not a valid WEBP header")
@@ -855,17 +857,17 b' def _webpxy(data):'
855 857
856 858 class Image(DisplayObject):
857 859
858 _read_flags = 'rb'
859 _FMT_JPEG = u'jpeg'
860 _FMT_PNG = u'png'
861 _FMT_GIF = u'gif'
862 _FMT_WEBP = u'webp'
860 _read_flags = "rb"
861 _FMT_JPEG = "jpeg"
862 _FMT_PNG = "png"
863 _FMT_GIF = "gif"
864 _FMT_WEBP = "webp"
863 865 _ACCEPTABLE_EMBEDDINGS = [_FMT_JPEG, _FMT_PNG, _FMT_GIF, _FMT_WEBP]
864 866 _MIMETYPES = {
865 _FMT_PNG: 'image/png',
866 _FMT_JPEG: 'image/jpeg',
867 _FMT_GIF: 'image/gif',
868 _FMT_WEBP: 'image/webp',
867 _FMT_PNG: "image/png",
868 _FMT_JPEG: "image/jpeg",
869 _FMT_GIF: "image/gif",
870 _FMT_WEBP: "image/webp",
869 871 }
870 872
871 873 def __init__(
@@ -987,7 +989,7 b' class Image(DisplayObject):'
987 989 format = self._FMT_PNG
988 990 elif ext == u'gif':
989 991 format = self._FMT_GIF
990 elif ext == u'webp':
992 elif ext == "webp":
991 993 format = self._FMT_WEBP
992 994 else:
993 995 format = ext.lower()
General Comments 0
You need to be logged in to leave comments. Login now