mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Fixed combining single duration across duplicate PNG frames
This commit is contained in:
parent
2a274a4760
commit
a0b691a219
|
@ -440,6 +440,12 @@ def test_apng_save_duration_loop(tmp_path):
|
|||
assert im.n_frames == 1
|
||||
assert im.info.get("duration") == 750
|
||||
|
||||
# test removal of duplicated frames with a single duration
|
||||
frame.save(test_file, save_all=True, append_images=[frame, frame], duration=500)
|
||||
with Image.open(test_file) as im:
|
||||
assert im.n_frames == 1
|
||||
assert im.info.get("duration") == 1500
|
||||
|
||||
# test info duration
|
||||
frame.info["duration"] = 750
|
||||
frame.save(test_file, save_all=True)
|
||||
|
|
|
@ -1146,11 +1146,14 @@ def _write_multiple_frames(im, fp, chunk, rawmode, default_image, append_images)
|
|||
and prev_disposal == encoderinfo.get("disposal")
|
||||
and prev_blend == encoderinfo.get("blend")
|
||||
):
|
||||
if isinstance(duration, (list, tuple)):
|
||||
previous["encoderinfo"]["duration"] += encoderinfo["duration"]
|
||||
previous["encoderinfo"]["duration"] += encoderinfo.get(
|
||||
"duration", duration
|
||||
)
|
||||
continue
|
||||
else:
|
||||
bbox = None
|
||||
if "duration" not in encoderinfo:
|
||||
encoderinfo["duration"] = duration
|
||||
im_frames.append({"im": im_frame, "bbox": bbox, "encoderinfo": encoderinfo})
|
||||
|
||||
# animation control
|
||||
|
@ -1175,7 +1178,7 @@ def _write_multiple_frames(im, fp, chunk, rawmode, default_image, append_images)
|
|||
im_frame = im_frame.crop(bbox)
|
||||
size = im_frame.size
|
||||
encoderinfo = frame_data["encoderinfo"]
|
||||
frame_duration = int(round(encoderinfo.get("duration", duration)))
|
||||
frame_duration = int(round(encoderinfo["duration"]))
|
||||
frame_disposal = encoderinfo.get("disposal", disposal)
|
||||
frame_blend = encoderinfo.get("blend", blend)
|
||||
# frame control
|
||||
|
|
Loading…
Reference in New Issue
Block a user