Do not use first frame duration for other frames when saving APNG images by radarhere · Pull Request #8104 · python-pillow/Pillow

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.