Handle disposing background from outside palette

This commit is contained in:
Andrew Murray 2023-11-02 16:05:13 +11:00
parent c9f7a8209b
commit 7c2b681183
3 changed files with 8 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View File

@ -1142,6 +1142,12 @@ def test_rgba_transparency(tmp_path):
assert_image_equal(hopper("P").convert("RGB"), reloaded)
def test_background_outside_palettte(tmp_path):
with Image.open("Tests/images/background_outside_palette.gif") as im:
im.seek(1)
assert im.info["background"] == 255
def test_bbox(tmp_path):
out = str(tmp_path / "temp.gif")

View File

@ -335,6 +335,8 @@ class GifImageFile(ImageFile.ImageFile):
def _rgb(color):
if self._frame_palette:
if color * 3 + 3 > len(self._frame_palette.palette):
color = 0
color = tuple(self._frame_palette.palette[color * 3 : color * 3 + 3])
else:
color = (color, color, color)