Allow for unknown PNG chunks after image data

This commit is contained in:
Andrew Murray 2019-01-08 07:21:25 +11:00
parent 7bf5246b93
commit 4e0a73b4fa
2 changed files with 4 additions and 8 deletions

View File

@ -596,6 +596,7 @@ class TestFilePng(PillowTestCase):
im = Image.open("Tests/images/iss634.apng")
self.assertEqual(im.get_format_mimetype(), 'image/apng')
# This also tests reading unknown PNG chunks (fcTL and fdAT) in load_end
expected = Image.open("Tests/images/iss634.webp")
self.assert_image_similar(im, expected, 0.23)

View File

@ -533,14 +533,6 @@ class PngStream(ChunkStream):
self.im_custom_mimetype = 'image/apng'
return s
def chunk_fcTL(self, pos, length):
s = ImageFile._safe_read(self.fp, length)
return s
def chunk_fdAT(self, pos, length):
s = ImageFile._safe_read(self.fp, length)
return s
# --------------------------------------------------------------------
# PNG reader
@ -682,6 +674,9 @@ class PngImageFile(ImageFile.ImageFile):
break
except EOFError:
ImageFile._safe_read(self.fp, length)
except AttributeError:
logger.debug("%r %s %s (unknown)", cid, pos, length)
ImageFile._safe_read(self.fp, length)
self._text = self.png.im_text
self.png.close()
self.png = None