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

Fixed using info dictionary when writing multiple APNG frames #5611

Merged
merged 2 commits into from Aug 24, 2021

Conversation

radarhere
Copy link
Member

Two changes here.

  1. Fixed using info dictionary when writing multiple APNG frames.

duration can come from encoderinfo or info when saving multiple frames.

duration = im.encoderinfo.get("duration", im.info.get("duration", 0))

The duration variable is only part of the individual frame's encoderinfo when it is a list or tuple though, or if it was part of the actual image's encoderinfo.

encoderinfo = im.encoderinfo.copy()
if isinstance(duration, (list, tuple)):
encoderinfo["duration"] = duration[frame_count]

So when it comes to fetch it for writing, it is ignored.

disposal = frame_data["encoderinfo"].get("disposal", APNG_DISPOSE_OP_NONE)

The same applies to disposal and blend.

  1. if "duration" in previous["encoderinfo"]:
    previous["encoderinfo"]["duration"] += frame_duration
    else:
    previous["encoderinfo"]["duration"] = frame_duration

Duration is either specified for every frame (in which case the condition is true), or a single value is used (in which case previous["encoderinfo"]["duration"] = frame_duration is unnecessary). So the else code can be removed.

@hugovk hugovk merged commit d5d6c3b into python-pillow:master Aug 24, 2021
@radarhere radarhere deleted the apng_info branch August 24, 2021 09:07
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.

None yet

2 participants