Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated TIFF tile descriptors to match current decoding functionality #3795

Merged
merged 4 commits into from Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions Tests/test_file_libtiff.py
Expand Up @@ -121,7 +121,7 @@ def test_adobe_deflate_tiff(self):

self.assertEqual(im.mode, "RGB")
self.assertEqual(im.size, (278, 374))
self.assertEqual(im.tile[0][:3], ("tiff_adobe_deflate", (0, 0, 278, 374), 0))
self.assertEqual(im.tile[0][:3], ("libtiff", (0, 0, 278, 374), 0))
im.load()

self.assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png")
Expand Down Expand Up @@ -644,10 +644,10 @@ def test_16bit_RGB_tiff(self):
im.tile,
[
(
"tiff_adobe_deflate",
"libtiff",
(0, 0, 100, 40),
0,
("RGB;16N", "tiff_adobe_deflate", False),
("RGB;16N", "tiff_adobe_deflate", False, 8),
)
],
)
Expand All @@ -661,7 +661,8 @@ def test_16bit_RGBa_tiff(self):
self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (100, 40))
self.assertEqual(
im.tile, [("tiff_lzw", (0, 0, 100, 40), 0, ("RGBa;16N", "tiff_lzw", False))]
im.tile,
[("libtiff", (0, 0, 100, 40), 0, ("RGBa;16N", "tiff_lzw", False, 38236))],
)
im.load()

Expand All @@ -680,7 +681,7 @@ def test_gimp_tiff(self):
self.assertEqual(im.mode, "RGB")
self.assertEqual(im.size, (256, 256))
self.assertEqual(
im.tile, [("jpeg", (0, 0, 256, 256), 0, ("RGB", "jpeg", False))]
im.tile, [("libtiff", (0, 0, 256, 256), 0, ("RGB", "jpeg", False, 5122))]
)
im.load()

Expand Down
6 changes: 3 additions & 3 deletions src/PIL/TiffImagePlugin.py
Expand Up @@ -1121,7 +1121,7 @@ def _load_libtiff(self):
# (self._compression, (extents tuple),
# 0, (rawmode, self._compression, fp))
extents = self.tile[0][1]
args = list(self.tile[0][3]) + [self.tag_v2.offset]
args = list(self.tile[0][3])

# To be nice on memory footprint, if there's a
# file descriptor, use that instead of reading
Expand Down Expand Up @@ -1328,8 +1328,8 @@ def _setup(self):

# Offset in the tile tuple is 0, we go from 0,0 to
# w,h, and we only do this once -- eds
a = (rawmode, self._compression, False)
self.tile.append((self._compression, (0, 0, xsize, ysize), 0, a))
a = (rawmode, self._compression, False, self.tag_v2.offset)
self.tile.append(("libtiff", (0, 0, xsize, ysize), 0, a))

elif STRIPOFFSETS in self.tag_v2 or TILEOFFSETS in self.tag_v2:
# striped image
Expand Down