mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Merge pull request #1782 from radarhere/compression
Different frames may have different compression types
This commit is contained in:
commit
26970c5e21
|
@ -991,6 +991,11 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
|
||||
return args
|
||||
|
||||
def load(self):
|
||||
if self.use_load_libtiff:
|
||||
return self._load_libtiff()
|
||||
return super(TiffImageFile, self).load()
|
||||
|
||||
def _load_libtiff(self):
|
||||
""" Overload method triggered when we detect a compressed tiff
|
||||
Calls out to libtiff """
|
||||
|
@ -1136,6 +1141,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
# build tile descriptors
|
||||
x = y = l = 0
|
||||
self.tile = []
|
||||
self.use_load_libtiff = False
|
||||
if STRIPOFFSETS in self.tag_v2:
|
||||
# striped image
|
||||
offsets = self.tag_v2[STRIPOFFSETS]
|
||||
|
@ -1158,10 +1164,9 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
# function.
|
||||
#
|
||||
# Setup the one tile for the whole image, then
|
||||
# replace the existing load function with our
|
||||
# _load_libtiff function.
|
||||
# use the _load_libtiff function.
|
||||
|
||||
self.load = self._load_libtiff
|
||||
self.use_load_libtiff = True
|
||||
|
||||
# To be nice on memory footprint, if there's a
|
||||
# file descriptor, use that instead of reading
|
||||
|
|
BIN
Tests/images/compression.tif
Executable file
BIN
Tests/images/compression.tif
Executable file
Binary file not shown.
|
@ -378,6 +378,22 @@ class TestFileTiff(PillowTestCase):
|
|||
self.assertEqual(im.tag_v2[X_RESOLUTION], 36)
|
||||
self.assertEqual(im.tag_v2[Y_RESOLUTION], 72)
|
||||
|
||||
def test_multipage_compression(self):
|
||||
im = Image.open('Tests/images/compression.tif')
|
||||
|
||||
im.seek(0)
|
||||
self.assertEqual(im._compression,'tiff_ccitt')
|
||||
self.assertEqual(im.size, (10, 10))
|
||||
|
||||
im.seek(1)
|
||||
self.assertEqual(im._compression,'packbits')
|
||||
self.assertEqual(im.size, (10, 10))
|
||||
im.load()
|
||||
|
||||
im.seek(0)
|
||||
self.assertEqual(im._compression,'tiff_ccitt')
|
||||
self.assertEqual(im.size, (10, 10))
|
||||
im.load()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user