mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Handle disposing background from outside palette
This commit is contained in:
parent
c9f7a8209b
commit
7c2b681183
BIN
Tests/images/background_outside_palette.gif
Normal file
BIN
Tests/images/background_outside_palette.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 B |
|
@ -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")
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user