From 0a877a527d0cc4c8df177c2945e64e636209a953 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 13 Mar 2019 19:07:55 +1100 Subject: [PATCH] Speed up n_frames by skipping past the last frame already seeked --- src/PIL/TiffImagePlugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 6ebc05ec1..3fced8a21 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -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)