Speed up n_frames by skipping past the last frame already seeked

This commit is contained in:
Andrew Murray 2019-03-13 19:07:55 +11:00
parent be80b083e5
commit 0a877a527d

View File

@ -998,6 +998,7 @@ class TiffImageFile(ImageFile.ImageFile):
def n_frames(self):
if self._n_frames is None:
current = self.tell()
self._seek(len(self._frame_pos))
while self._n_frames is None:
self._seek(self.tell() + 1)
self.seek(current)