Skip to content

Commit

Permalink
Updated TIFF tile descriptors to match current decoding functio… (#3795)
Browse files Browse the repository at this point in the history
Updated TIFF tile descriptors to match current decoding functionality
  • Loading branch information
hugovk committed Jun 29, 2019
2 parents 08c4792 + d00e18b commit 0e7358a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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

0 comments on commit 0e7358a

Please sign in to comment.