Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

2 participants