Fixed saving L mode GIF with background as WebP

This commit is contained in:
Andrew Murray 2022-03-21 20:09:53 +11:00
parent a6a843e548
commit b0d0d2b9cc
3 changed files with 9 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 B

View File

@ -187,6 +187,12 @@ class TestFileWebp:
@skip_unless_feature("webp_anim")
def test_background_from_gif(self, tmp_path):
# Save L mode GIF with background
with Image.open("Tests/images/no_palette_with_background.gif") as im:
out_webp = str(tmp_path / "temp.webp")
im.save(out_webp, save_all=True)
# Save P mode GIF with background
with Image.open("Tests/images/chi.gif") as im:
original_value = im.convert("RGB").getpixel((1, 1))

View File

@ -190,7 +190,9 @@ def _save_all(im, fp, filename):
palette = im.getpalette()
if palette:
r, g, b = palette[background * 3 : (background + 1) * 3]
background = (r, g, b, 0)
background = (r, g, b, 255)
else:
background = (background, background, background, 255)
duration = im.encoderinfo.get("duration", im.info.get("duration", 0))
loop = im.encoderinfo.get("loop", 0)