Skip to content

Commit ca0738d

Browse files
authored
Merge pull request #1 from radarhere/round-error
Added test
2 parents 45aec95 + ca16cf2 commit ca0738d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Tests/test_file_apng.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ def test_apng_save_duration_loop(tmp_path):
433433

434434
# test removal of duplicated frames
435435
frame = Image.new("RGBA", (128, 64), (255, 0, 0, 255))
436-
frame.save(test_file, save_all=True, append_images=[frame], duration=[500, 250])
436+
frame.save(
437+
test_file, save_all=True, append_images=[frame, frame], duration=[500, 100, 150]
438+
)
437439
with Image.open(test_file) as im:
438440
im.load()
439441
assert im.n_frames == 1

src/PIL/PngImagePlugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,12 +1117,12 @@ def _write_multiple_frames(im, fp, chunk, rawmode):
11171117
and prev_disposal == encoderinfo.get("disposal")
11181118
and prev_blend == encoderinfo.get("blend")
11191119
):
1120-
now_duration = encoderinfo.get("duration", 0)
1121-
if now_duration:
1120+
frame_duration = encoderinfo.get("duration", 0)
1121+
if frame_duration:
11221122
if "duration" in previous["encoderinfo"]:
1123-
previous["encoderinfo"]["duration"] += now_duration
1123+
previous["encoderinfo"]["duration"] += frame_duration
11241124
else:
1125-
previous["encoderinfo"]["duration"] = now_duration
1125+
previous["encoderinfo"]["duration"] = frame_duration
11261126
continue
11271127
else:
11281128
bbox = None

0 commit comments

Comments
 (0)