From a26a584812d7e9b1f4d1d98797ea95e10b1e52d6 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 22 May 2017 19:38:38 +0300 Subject: [PATCH] Do not raise SyntaxError for wrong chunks (just ignore them) --- PIL/PngImagePlugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index 5e5eb14c7..e329a6c0d 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -113,7 +113,8 @@ class ChunkStream(object): length = i32(s) if not is_cid(cid): - raise SyntaxError("broken PNG file (chunk %s)" % repr(cid)) + if not ImageFile.LOAD_TRUNCATED_IMAGES: + raise SyntaxError("broken PNG file (chunk %s)" % repr(cid)) return cid, pos, length