mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-14 03:21:44 +03:00
Merge pull request #5443 from radarhere/fp
This commit is contained in:
commit
23f848ea54
|
@ -578,6 +578,17 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
|
||||
TiffImagePlugin.READ_LIBTIFF = False
|
||||
|
||||
def test_multipage_seek_backwards(self):
|
||||
TiffImagePlugin.READ_LIBTIFF = True
|
||||
with Image.open("Tests/images/multipage.tiff") as im:
|
||||
im.seek(1)
|
||||
im.load()
|
||||
|
||||
im.seek(0)
|
||||
assert im.convert("RGB").getpixel((0, 0)) == (0, 128, 0)
|
||||
|
||||
TiffImagePlugin.READ_LIBTIFF = False
|
||||
|
||||
def test__next(self):
|
||||
TiffImagePlugin.READ_LIBTIFF = True
|
||||
with Image.open("Tests/images/hopper.tif") as im:
|
||||
|
|
|
@ -1053,6 +1053,11 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
|
||||
def _seek(self, frame):
|
||||
self.fp = self.__fp
|
||||
|
||||
# reset buffered io handle in case fp
|
||||
# was passed to libtiff, invalidating the buffer
|
||||
self.fp.tell()
|
||||
|
||||
while len(self._frame_pos) <= frame:
|
||||
if not self.__next:
|
||||
raise EOFError("no more images in TIFF file")
|
||||
|
@ -1060,9 +1065,6 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
f"Seeking to frame {frame}, on frame {self.__frame}, "
|
||||
f"__next {self.__next}, location: {self.fp.tell()}"
|
||||
)
|
||||
# reset buffered io handle in case fp
|
||||
# was passed to libtiff, invalidating the buffer
|
||||
self.fp.tell()
|
||||
self.fp.seek(self.__next)
|
||||
self._frame_pos.append(self.__next)
|
||||
logger.debug("Loading tags, location: %s" % self.fp.tell())
|
||||
|
|
Loading…
Reference in New Issue
Block a user