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

Do not use first frame duration for other frames when saving APNG images #8104

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Jun 4, 2024

Resolves #8102

When saving APNG images, if there is no duration argument given to the save() command, then duration is pulled from the first image's info dictionary.

def _write_multiple_frames(im, fp, chunk, rawmode, default_image, append_images):
duration = im.encoderinfo.get("duration", im.info.get("duration", 0))

That value is later re-used for subsequent frames, leading to the unexpected behaviour in the issue.

if "duration" not in encoderinfo:
encoderinfo["duration"] = duration

This PR corrects this, using GifImagePlugin's _write_multiple_frames() as a model.

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a conflict.

@hugovk hugovk merged commit a4188bb into python-pillow:main Jun 25, 2024
56 checks passed
@radarhere radarhere deleted the apng branch June 25, 2024 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saving to apng has wrong durations
2 participants