mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 01:34:24 +03:00
Automatically populate _n_frames if seeking to the last frame
This commit is contained in:
parent
d84fd20f0c
commit
be80b083e5
|
@ -998,11 +998,8 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
def n_frames(self):
|
def n_frames(self):
|
||||||
if self._n_frames is None:
|
if self._n_frames is None:
|
||||||
current = self.tell()
|
current = self.tell()
|
||||||
try:
|
while self._n_frames is None:
|
||||||
while True:
|
self._seek(self.tell() + 1)
|
||||||
self._seek(self.tell() + 1)
|
|
||||||
except EOFError:
|
|
||||||
self._n_frames = self.tell() + 1
|
|
||||||
self.seek(current)
|
self.seek(current)
|
||||||
return self._n_frames
|
return self._n_frames
|
||||||
|
|
||||||
|
@ -1039,6 +1036,8 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
print("Loading tags, location: %s" % self.fp.tell())
|
print("Loading tags, location: %s" % self.fp.tell())
|
||||||
self.tag_v2.load(self.fp)
|
self.tag_v2.load(self.fp)
|
||||||
self.__next = self.tag_v2.next
|
self.__next = self.tag_v2.next
|
||||||
|
if self.__next == 0:
|
||||||
|
self._n_frames = frame + 1
|
||||||
if len(self._frame_pos) == 1:
|
if len(self._frame_pos) == 1:
|
||||||
self._is_animated = self.__next != 0
|
self._is_animated = self.__next != 0
|
||||||
self.__frame += 1
|
self.__frame += 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user