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

Fixed calling putpalette() on L and LA images before load() #7187

Merged
merged 1 commit into from Jun 13, 2023

Conversation

radarhere
Copy link
Member

Address the problem raised in #7186

putpalette()'s strategy for attaching a palette to an image is to change the mode, set the palette, and then call load().

Pillow/src/PIL/Image.py

Lines 1918 to 1921 in 117618b

self.mode = "PA" if "A" in self.mode else "P"
self.palette = palette
self.palette.mode = "RGB"
self.load() # install new palette

We have been testing this with all of the valid modes.

However, the user found an error when calling putpalette() on an image directly after opening it, before load() is called. This means that L and LA images are attempted to be unpacked directly into P and PA images respectively, which Unpack.c doesn't currently support.

This PR fixes that.

@hugovk hugovk merged commit c62c514 into python-pillow:main Jun 13, 2023
60 checks passed
@radarhere radarhere deleted the putpalette branch June 13, 2023 21:54
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.

None yet

2 participants