mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Merge pull request #3713 from radarhere/tiff_seek
Fixed TIFF bug when seeking backwards and then forwards
This commit is contained in:
commit
82848905e6
|
@ -263,6 +263,11 @@ class TestFileTiff(PillowTestCase):
|
||||||
self.assertEqual(im.size, (10, 10))
|
self.assertEqual(im.size, (10, 10))
|
||||||
self.assertEqual(im.convert('RGB').getpixel((0, 0)), (255, 0, 0))
|
self.assertEqual(im.convert('RGB').getpixel((0, 0)), (255, 0, 0))
|
||||||
|
|
||||||
|
im.seek(0)
|
||||||
|
im.load()
|
||||||
|
self.assertEqual(im.size, (10, 10))
|
||||||
|
self.assertEqual(im.convert('RGB').getpixel((0, 0)), (0, 128, 0))
|
||||||
|
|
||||||
im.seek(2)
|
im.seek(2)
|
||||||
im.load()
|
im.load()
|
||||||
self.assertEqual(im.size, (20, 20))
|
self.assertEqual(im.size, (20, 20))
|
||||||
|
|
|
@ -1056,7 +1056,6 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
self.__frame += 1
|
self.__frame += 1
|
||||||
self.fp.seek(self._frame_pos[frame])
|
self.fp.seek(self._frame_pos[frame])
|
||||||
self.tag_v2.load(self.fp)
|
self.tag_v2.load(self.fp)
|
||||||
self.__next = self.tag_v2.next
|
|
||||||
# fill the legacy tag/ifd entries
|
# fill the legacy tag/ifd entries
|
||||||
self.tag = self.ifd = ImageFileDirectory_v1.from_v2(self.tag_v2)
|
self.tag = self.ifd = ImageFileDirectory_v1.from_v2(self.tag_v2)
|
||||||
self.__frame = frame
|
self.__frame = frame
|
||||||
|
@ -1087,7 +1086,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
def load_end(self):
|
def load_end(self):
|
||||||
# allow closing if we're on the first frame, there's no next
|
# allow closing if we're on the first frame, there's no next
|
||||||
# This is the ImageFile.load path only, libtiff specific below.
|
# This is the ImageFile.load path only, libtiff specific below.
|
||||||
if self.__frame == 0 and not self.__next:
|
if len(self._frame_pos) == 1 and not self.__next:
|
||||||
self._close_exclusive_fp_after_loading = True
|
self._close_exclusive_fp_after_loading = True
|
||||||
|
|
||||||
def _load_libtiff(self):
|
def _load_libtiff(self):
|
||||||
|
@ -1168,7 +1167,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
self.readonly = 0
|
self.readonly = 0
|
||||||
# libtiff closed the fp in a, we need to close self.fp, if possible
|
# libtiff closed the fp in a, we need to close self.fp, if possible
|
||||||
if self._exclusive_fp:
|
if self._exclusive_fp:
|
||||||
if self.__frame == 0 and not self.__next:
|
if len(self._frame_pos) == 1 and not self.__next:
|
||||||
self.fp.close()
|
self.fp.close()
|
||||||
self.fp = None # might be shared
|
self.fp = None # might be shared
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user