From 33bf5d9d37d377c43ac38be497b1e9cdd1d34832 Mon Sep 17 00:00:00 2001 From: David Schmidt Date: Fri, 11 Jan 2013 14:40:02 +0100 Subject: [PATCH] Improved load truncated images --- PIL/ImageFile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index 688c33a1d..3b60c0d05 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -226,9 +226,8 @@ class ImageFile(Image.Image): self.fp = None # might be shared - if not LOAD_TRUNCATED_IMAGES and not self.map and e < 0: - # Note: If loading a truncated image results in an all black Image, - # the decoder wasn't able to decode anything. + if (t == 0 or not LOAD_TRUNCATED_IMAGES) and not self.map and e < 0: + # still raised if decoder fails to return anything raise_ioerror(e) # post processing