Skip to content

Commit ccfe33f

Browse files
authored
Merge pull request #7515 from radarhere/gif
2 parents 7e30619 + 7c2b681 commit ccfe33f

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed
82 Bytes
Loading

Tests/test_file_gif.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,12 @@ def test_rgba_transparency(tmp_path):
11421142
assert_image_equal(hopper("P").convert("RGB"), reloaded)
11431143

11441144

1145+
def test_background_outside_palettte(tmp_path):
1146+
with Image.open("Tests/images/background_outside_palette.gif") as im:
1147+
im.seek(1)
1148+
assert im.info["background"] == 255
1149+
1150+
11451151
def test_bbox(tmp_path):
11461152
out = str(tmp_path / "temp.gif")
11471153

src/PIL/GifImagePlugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ def _seek(self, frame, update_image=True):
330330

331331
def _rgb(color):
332332
if self._frame_palette:
333+
if color * 3 + 3 > len(self._frame_palette.palette):
334+
color = 0
333335
color = tuple(self._frame_palette.palette[color * 3 : color * 3 + 3])
334336
else:
335337
color = (color, color, color)

0 commit comments

Comments
 (0)