Skip to content

Commit ddebe27

Browse files
authored
Merge pull request #4565 from radarhere/tiff_pickle
Fixed bug when unpickling TIFF images
2 parents 4a909b9 + 9956a6c commit ddebe27

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

Tests/test_pickle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def helper_pickle_string(pickle, protocol, test_file, mode):
4545
pytest.param(
4646
"Tests/images/hopper.webp", None, marks=skip_unless_feature("webp")
4747
),
48+
("Tests/images/hopper.tif", None),
4849
("Tests/images/test-card.png", None),
4950
("Tests/images/zero_bb.png", None),
5051
("Tests/images/zero_bb_scale2.png", None),

src/PIL/TiffImagePlugin.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ def tell(self):
10661066
return self.__frame
10671067

10681068
def load(self):
1069-
if self.use_load_libtiff:
1069+
if self.tile and self.use_load_libtiff:
10701070
return self._load_libtiff()
10711071
return super().load()
10721072

@@ -1094,12 +1094,7 @@ def _load_libtiff(self):
10941094
""" Overload method triggered when we detect a compressed tiff
10951095
Calls out to libtiff """
10961096

1097-
if self.tile is None:
1098-
raise OSError("cannot load this image")
1099-
1100-
pixel = Image.Image.load(self)
1101-
if not self.tile:
1102-
return pixel
1097+
Image.Image.load(self)
11031098

11041099
self.load_prepare()
11051100

0 commit comments

Comments
 (0)