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
Color palette not working with the latest version of Pillow #7561
Comments
Could you provide the inputs for your code so that we can test it exactly? I gather there are 7 arguments, including an image and a file. What are the arguments? Could you attach those files here? |
data.zip |
#7289 set an image's C palette to be empty by default. In your case, this has the effect of If you replace colorscale=[[i/255.0, "rgb({}, {}, {})".format(*rgb)] for i, rgb in enumerate(idx_to_color)] with colorscale = []
for i in range(256):
rgb = idx_to_color[i] if i < len(idx_to_color) else (0, 0, 0)
colorscale.append([i/255.0, "rgb({}, {}, {})".format(*rgb)]) I think the problem should be resolved. |
Hello! We are also running into the same or very similiar issues with palettes, for us resulting in IndexErrors. Failing test pipeline: It's the first failing test, the second can be disregarded, this is just due to the new default font. This is an editing library for an old video game which uses paletted images. Should this not be considered a bug, could this change be documented in the changelog? Edit: Reading your previous comment I guess it's any indexed images, no matter how it was created. |
I don't think of this as a bug. The palette isn't missing useful information - it's no longer returning redundant information. I don't think it was ever documented that So the Pillow 10.1.0 change in behaviour is just a continuation of that. You might find this odd, but given that your package works with a ROM, I'm unsure about the legal status of your package, and correspondingly whether I want to assist you in that. |
The fix you propose @radarhere works! Thanks a lot for your help! Valérie |
What did you do?
I am trying to color a 3D map with a color palette
What did you expect to happen?
Results are perfect with Pillow 9.4.0, but comes out with wrong colors with 10.1.0
What actually happened?
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: