Skip to content

Commit

Permalink
Added default duration of zero
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Mar 17, 2022
1 parent 0cf072d commit c8fddbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Tests/test_file_webp.py
Expand Up @@ -8,6 +8,7 @@
from PIL import Image, WebPImagePlugin, features

from .helper import (
assert_image_equal,
assert_image_similar,
assert_image_similar_tofile,
hopper,
Expand Down Expand Up @@ -105,6 +106,18 @@ def test_write_method(self, tmp_path):
hopper().save(buffer_method, format="WEBP", method=6)
assert buffer_no_args.getbuffer() != buffer_method.getbuffer()

def test_save_all(self, tmp_path):
temp_file = str(tmp_path / "temp.webp")
im = Image.new("RGB", (1, 1))
im2 = Image.new("RGB", (1, 1), "#f00")
im.save(temp_file, save_all=True, append_images=[im2])

with Image.open(temp_file) as reloaded:
assert_image_equal(im, reloaded)

reloaded.seek(1)
assert_image_similar(im2, reloaded, 1)

def test_icc_profile(self, tmp_path):
self._roundtrip(tmp_path, self.rgb_mode, 12.5, {"icc_profile": None})
if _webp.HAVE_WEBPANIM:
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/WebPImagePlugin.py
Expand Up @@ -192,7 +192,7 @@ def _save_all(im, fp, filename):
r, g, b = palette[background * 3 : (background + 1) * 3]
background = (r, g, b, 0)

duration = im.encoderinfo.get("duration", im.info.get("duration"))
duration = im.encoderinfo.get("duration", im.info.get("duration", 0))
loop = im.encoderinfo.get("loop", 0)
minimize_size = im.encoderinfo.get("minimize_size", False)
kmin = im.encoderinfo.get("kmin", None)
Expand Down

0 comments on commit c8fddbd

Please sign in to comment.