From 9956a6c777d55b5ee0e17208bea6a138bbd8baf8 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 17 Apr 2020 22:13:14 +1000 Subject: [PATCH] Fixed bug when unpickling TIFF images --- Tests/test_pickle.py | 1 + src/PIL/TiffImagePlugin.py | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index 4bf6d586a..3e44e99ef 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -49,6 +49,7 @@ def helper_pickle_string( pytest.param( "Tests/images/hopper.webp", None, marks=skip_unless_feature("webp") ), + ("Tests/images/hopper.tif", None), ("Tests/images/test-card.png", None), ("Tests/images/zero_bb.png", None), ("Tests/images/zero_bb_scale2.png", None), diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index e8d82ae46..f9e0ad070 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1066,7 +1066,7 @@ class TiffImageFile(ImageFile.ImageFile): return self.__frame def load(self): - if self.use_load_libtiff: + if self.tile and self.use_load_libtiff: return self._load_libtiff() return super().load() @@ -1094,12 +1094,7 @@ class TiffImageFile(ImageFile.ImageFile): """ Overload method triggered when we detect a compressed tiff Calls out to libtiff """ - if self.tile is None: - raise OSError("cannot load this image") - - pixel = Image.Image.load(self) - if not self.tile: - return pixel + Image.Image.load(self) self.load_prepare()