Skip to content

Commit

Permalink
Merge pull request #7515 from radarhere/gif
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Dec 21, 2023
2 parents 7e30619 + 7c2b681 commit ccfe33f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Binary file added Tests/images/background_outside_palette.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Tests/test_file_gif.py
Expand Up @@ -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")

Expand Down
2 changes: 2 additions & 0 deletions src/PIL/GifImagePlugin.py
Expand Up @@ -330,6 +330,8 @@ def _seek(self, frame, update_image=True):

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)
Expand Down

0 comments on commit ccfe33f

Please sign in to comment.