Show More
@@ -637,7 +637,7 b' class Image(DisplayObject):' | |||
|
637 | 637 | _FMT_PNG = u'png' |
|
638 | 638 | _ACCEPTABLE_EMBEDDINGS = [_FMT_JPEG, _FMT_PNG] |
|
639 | 639 | |
|
640 |
def __init__(self, data=None, url=None, filename=None, format= |
|
|
640 | def __init__(self, data=None, url=None, filename=None, format=None, | |
|
641 | 641 | embed=None, width=None, height=None, retina=False, |
|
642 | 642 | unconfined=False, metadata=None): |
|
643 | 643 | """Create a PNG/JPEG image object given raw data. |
@@ -714,17 +714,27 b' class Image(DisplayObject):' | |||
|
714 | 714 | else: |
|
715 | 715 | ext = None |
|
716 | 716 | |
|
717 |
if |
|
|
718 |
f |
|
|
719 | if ext == u'jpg' or ext == u'jpeg': | |
|
720 | format = self._FMT_JPEG | |
|
721 | if ext == u'png': | |
|
722 | format = self._FMT_PNG | |
|
723 | elif isinstance(data, bytes) and format == 'png': | |
|
724 | # infer image type from image data header, | |
|
725 | # only if format might not have been specified. | |
|
726 | if data[:2] == _JPEG: | |
|
727 | format = 'jpeg' | |
|
717 | if format is None: | |
|
718 | if ext is not None: | |
|
719 | if ext == u'jpg' or ext == u'jpeg': | |
|
720 | format = self._FMT_JPEG | |
|
721 | if ext == u'png': | |
|
722 | format = self._FMT_PNG | |
|
723 | else: | |
|
724 | format = ext.lower() | |
|
725 | elif isinstance(data, bytes): | |
|
726 | # infer image type from image data header, | |
|
727 | # only if format has not been specified. | |
|
728 | if data[:2] == _JPEG: | |
|
729 | format = self._FMT_JPEG | |
|
730 | ||
|
731 | if format.lower() == 'jpg': | |
|
732 | # jpg->jpeg | |
|
733 | format = self._FMT_JPEG | |
|
734 | ||
|
735 | # failed to detect format, default png | |
|
736 | if format is None: | |
|
737 | format = 'png' | |
|
728 | 738 | |
|
729 | 739 | self.format = unicode_type(format).lower() |
|
730 | 740 | 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