Skip to content

Commit

Permalink
Use current frame for transparency detection
Browse files Browse the repository at this point in the history
  • Loading branch information
homm committed Sep 16, 2024
1 parent d1f40a9 commit 31d36e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Tests/test_file_webp.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_invalid_background(

def test_background_from_gif(self, tmp_path: Path) -> None:
out_webp = tmp_path / "temp.webp"

# Save L mode GIF with background
with Image.open("Tests/images/no_palette_with_background.gif") as im:
im.save(out_webp, save_all=True)
Expand Down
4 changes: 3 additions & 1 deletion src/PIL/WebPImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
# Make sure image mode is supported
frame = ims
if frame.mode not in ("RGBX", "RGBA", "RGB"):
frame = frame.convert("RGBA" if im.has_transparency_data else "RGB")
frame = frame.convert(
"RGBA" if frame.has_transparency_data else "RGB"
)

# Append the frame to the animation encoder
enc.add(
Expand Down

0 comments on commit 31d36e6

Please sign in to comment.