From 4e0a73b4faf4c0b16c6b3912b64f4ad7a6c99acf Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 8 Jan 2019 07:21:25 +1100 Subject: [PATCH] Allow for unknown PNG chunks after image data --- Tests/test_file_png.py | 1 + src/PIL/PngImagePlugin.py | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index c94f8eaad..840174444 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -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) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index f3a2eaf21..0669ab216 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -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