Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #7311: "Read WebP duration after opening" #7406

Merged
merged 2 commits into from Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Tests/test_file_webp.py
Expand Up @@ -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
10 changes: 4 additions & 6 deletions src/PIL/WebPImagePlugin.py
Expand Up @@ -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 = []
Expand All @@ -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:
Expand All @@ -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
Expand Down