Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle disposing GIF background from outside palette #7515

Merged
merged 1 commit into from Dec 21, 2023

Conversation

radarhere
Copy link
Member

Resolves #7514

When disposing a GIF frame, Pillow doesn't currently consider that a background index might be higher than the current size of the palette. If that happens, the following code

color = tuple(self._frame_palette.palette[color * 3 : color * 3 + 3])

creates an empty tuple, leading to a TypeError when
self.dispose = Image.core.fill(dispose_mode, dispose_size, color)

tries to create an image filled with an empty tuple.

Instead, this PR uses the first palette entry in such a scenario. This is in line with our default if there is no background.

@radarhere radarhere added the GIF label Nov 2, 2023
@hugovk hugovk merged commit ccfe33f into python-pillow:main Dec 21, 2023
53 checks passed
@radarhere radarhere deleted the gif branch December 21, 2023 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Certain animated GIFs cause TypeError: color must be int, or tuple of one, three or four elements
2 participants