diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index d6d7be9c898..a27b7ac8817 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -865,6 +865,15 @@ def test_multipage_compression(self) -> None: assert im.size == (10, 10) im.load() + def test_seek_remove_palette(self) -> None: + with Image.open("Tests/images/no_rows_per_strip.tif") as im: + assert im.mode == "P" + assert im.palette is not None + + im.seek(1) + assert im.mode == "F" + assert im.palette is None + def test_save_tiff_with_jpegtables(self, tmp_path: Path) -> None: # Arrange outfile = tmp_path / "temp.tif" diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index db37ab7e4c9..538c2a1bd82 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1673,6 +1673,8 @@ def _setup(self) -> None: if self.mode in ["P", "PA"]: palette = [o8(b // 256) for b in self.tag_v2[COLORMAP]] self.palette = ImagePalette.raw("RGB;L", b"".join(palette)) + else: + self.palette = None #