Show More
@@ -420,6 +420,9 b' class Javascript(DisplayObject):' | |||
|
420 | 420 | r += lib_t2*len(self.lib) |
|
421 | 421 | return r |
|
422 | 422 | |
|
423 | # constants for identifying png/jpeg data | |
|
424 | _PNG = b'\x89PNG\r\n\x1a\n' | |
|
425 | _JPEG = b'\xff\xd8' | |
|
423 | 426 | |
|
424 | 427 | class Image(DisplayObject): |
|
425 | 428 | |
@@ -487,6 +490,11 b' class Image(DisplayObject):' | |||
|
487 | 490 | format = self._FMT_JPEG |
|
488 | 491 | if ext == u'png': |
|
489 | 492 | format = self._FMT_PNG |
|
493 | elif isinstance(data, bytes) and format == 'png': | |
|
494 | # infer image type from image data header, | |
|
495 | # only if format might not have been specified. | |
|
496 | if data[:2] == _JPEG: | |
|
497 | format = 'jpeg' | |
|
490 | 498 | |
|
491 | 499 | self.format = unicode(format).lower() |
|
492 | 500 | self.embed = embed if embed is not None else (url is None) |
General Comments 0
You need to be logged in to leave comments.
Login now