From 26c4798707ad65e63fea0560657cb0c2125ba6c6 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 18 Sep 2023 20:34:05 +1000 Subject: [PATCH] Revert "Merge pull request #7311 from k128/main" This reverts commit 39d866b17d99206c11d931e12c108825df68f47b, reversing changes made to f39f74fb82348ce87dfc9e4766ee473132ce84d3. --- Tests/test_file_webp.py | 1 + src/PIL/WebPImagePlugin.py | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index 3832441c02d..a7b6c735a69 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -233,4 +233,5 @@ def test_duration(self, tmp_path): im.save(out_webp, save_all=True) with Image.open(out_webp) as reloaded: + reloaded.load() assert reloaded.info["duration"] == 1000 diff --git a/src/PIL/WebPImagePlugin.py b/src/PIL/WebPImagePlugin.py index a6e1a2a00c5..028e5d2bdd9 100644 --- a/src/PIL/WebPImagePlugin.py +++ b/src/PIL/WebPImagePlugin.py @@ -74,9 +74,6 @@ def _open(self): self.info["background"] = (bg_r, bg_g, bg_b, bg_a) self.n_frames = frame_count self.is_animated = self.n_frames > 1 - ret = self._decoder.get_next() - if ret is not None: - self.info["duration"] = ret[1] self._mode = "RGB" if mode == "RGBX" else mode self.rawmode = mode self.tile = [] @@ -93,7 +90,7 @@ def _open(self): self.info["xmp"] = xmp # Initialize seek state - self._reset() + self._reset(reset=False) def _getexif(self): if "exif" not in self.info: @@ -116,8 +113,9 @@ def seek(self, frame): # Set logical frame to requested position self.__logical_frame = frame - def _reset(self): - self._decoder.reset() + def _reset(self, reset=True): + if reset: + self._decoder.reset() self.__physical_frame = 0 self.__loaded = -1 self.__timestamp = 0