Merge pull request #6779 from radarhere/gif_duration

Resolves https://github.com/python-pillow/Pillow/issues/6778
This commit is contained in:
Hugo van Kemenade 2022-12-13 18:14:28 +02:00 committed by GitHub
commit d013fbf656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

View File

@ -791,6 +791,22 @@ def test_roundtrip_info_duration(tmp_path):
] == duration_list
def test_roundtrip_info_duration_combined(tmp_path):
out = str(tmp_path / "temp.gif")
with Image.open("Tests/images/duplicate_frame.gif") as im:
assert [frame.info["duration"] for frame in ImageSequence.Iterator(im)] == [
1000,
1000,
1000,
]
im.save(out, save_all=True)
with Image.open(out) as reloaded:
assert [
frame.info["duration"] for frame in ImageSequence.Iterator(reloaded)
] == [1000, 2000]
def test_identical_frames(tmp_path):
duration_list = [1000, 1500, 2000, 4000]

View File

@ -618,7 +618,7 @@ def _write_multiple_frames(im, fp, palette):
bbox = delta.getbbox()
if not bbox:
# This frame is identical to the previous frame
if duration:
if encoderinfo.get("duration"):
previous["encoderinfo"]["duration"] += encoderinfo["duration"]
continue
else: