Skip to content

Commit

Permalink
Merge pull request #6996 from radarhere/webp
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Mar 23, 2023
2 parents 415455d + 459f0d8 commit 3d4a6f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Tests/test_file_webp_animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ def test_timestamp_and_duration(tmp_path):
ts += durations[frame]


def test_float_duration(tmp_path):
temp_file = str(tmp_path / "temp.webp")
with Image.open("Tests/images/iss634.apng") as im:
assert im.info["duration"] == 70.0

im.save(temp_file, save_all=True)

with Image.open(temp_file) as reloaded:
reloaded.load()
assert reloaded.info["duration"] == 70


def test_seeking(tmp_path):
"""
Create an animated WebP file, and then try seeking through frames in reverse-order,
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/WebPImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _save_all(im, fp, filename):
# Append the frame to the animation encoder
enc.add(
frame.tobytes("raw", rawmode),
timestamp,
round(timestamp),
frame.size[0],
frame.size[1],
rawmode,
Expand All @@ -305,7 +305,7 @@ def _save_all(im, fp, filename):
im.seek(cur_idx)

# Force encoder to flush frames
enc.add(None, timestamp, 0, 0, "", lossless, quality, 0)
enc.add(None, round(timestamp), 0, 0, "", lossless, quality, 0)

# Get the final output from the encoder
data = enc.assemble(icc_profile, exif, xmp)
Expand Down

0 comments on commit 3d4a6f7

Please sign in to comment.