Skip to content

Remove duration and timestamp from WebP info after seek#9791

Open
radarhere wants to merge 2 commits into
python-pillow:mainfrom
radarhere:webp
Open

Remove duration and timestamp from WebP info after seek#9791
radarhere wants to merge 2 commits into
python-pillow:mainfrom
radarhere:webp

Conversation

@radarhere

@radarhere radarhere commented Jul 14, 2026

Copy link
Copy Markdown
Member

Resolves #9790

As determined in #7311, Pillow doesn't read the duration of a WebP frame until after load(). However, it turns out that it keeps it until the next load().

from PIL import Image

im = Image.open("Tests/images/iss634.webp")
im.seek(1)
im.load()
print(im.info.get("duration"))  # The first frame has a duration of 70

im.seek(2)
im.load()
print(im.info.get("duration"))  # The second frame has a duration of 60

# However, imagine if a user did this
im = Image.open("Tests/images/iss634.webp")
im.seek(1)
im.load()
im.seek(2)
print(im.info.get("duration"))  # This is the second frame, but the duration is 70? That appears incorrect.

This PR removes duration and timestamp from info after seek(), so that the old information does not hang around and potentially confuse the user.

If the user only seek()s forward by one frame, I'm tempted to keep the timestamp, since it is easily determined from the timestamp and duration of the previous frame - but I think people would probably prefer the consistency of it being cleared after all seek()s.

@radarhere radarhere added the WebP label Jul 14, 2026
@radarhere radarhere changed the title Remove duration and timestamp from WEBP info after seek Remove duration and timestamp from WebP info after seek Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Animated webp does not populate info dictionary on seek

1 participant