-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
ImagePalette: loading a translucent RGBA color into an RGB palette will break the palette #6652
Comments
For context, the code to handle opaque RGBA colors was added in #5552. I think that raising a ValueError is the better solution. If Pillow just accepted the input, this could surprise the user later when they discover that the RGBA color isn't really there. |
Oh, -
So - do we use the RGB components? |
The error you're hitting is when the tests try to set an RGBA value for a P image. The test was changed to use a translucent value in #6504, which was a PR about allowing RGB and RGBA values for PA images. Setting a translucent value for a P image was a side-effect, not the intention. So I'm happy to change the test. I've created jsbueno#2 |
This is a minor thing:
In PIL/ImagePalette.py, we have
Pillow/src/PIL/ImagePalette.py
Lines 118 to 119 in 243402e
And then, this
color
is consumed in line 151, always assuming it is 3-bytes long (and having 4 would make colors from that point on "out of sync") . I was about to send a small PR raising value error in the unchecked case:But then, why not just truncate the alpha away, and always use the RGB value if an RGBA color is added to an RGB palette?
Can we do that?
(the sole purpose of this issue is to ask this question - I should submit fix + test afterwards)
The text was updated successfully, but these errors were encountered: