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

PIL doesn't seem to handle the color map correctly in some color indexed TGA files #4830

Closed
innovara opened this issue Jul 31, 2020 · 3 comments · Fixed by #5549
Closed

PIL doesn't seem to handle the color map correctly in some color indexed TGA files #4830

innovara opened this issue Jul 31, 2020 · 3 comments · Fixed by #5549
Labels
Bug Any unexpected behavior, until confirmed feature.

Comments

@innovara
Copy link

Please see my question in Stack Overflow where I explain everything in greater detail and more importantly, where Mark Setchell explains why he thinks there is a bug in PIL when handling some color indexed TGA files.

Basically, I am working with a sample color indexed TGA file to test a script that would invert its colors.

But before any of that, the issue is that PIL doesn't seem to handle the color map correctly when open it and the values of the color palette end up being wrong.

These are the sample files: CCM8.TGA and UCM8.TGA.
And you will see that if you open show any of them:

from PIL import Image
Image.open('CCM8.TGA').show()

PIL shows:
pQ6IH
When it should be:
IpPCy

As I said, I wrote all the details on that post. If you want me to submit more information here, please let me know.

I am using Pillow 7.0 on Fedora 32 and Python 3.8.

innovara added a commit to innovara/invert-colors that referenced this issue Jul 31, 2020
Still work in progress.

Can invert all colors on RGB, RGBA and P mode of the supported formats.

There is an issue with PIL which I have reported: python-pillow/Pillow#4830

Green channel inversion works too.

More testing and a lot of improvements to come.
@radarhere
Copy link
Member

radarhere commented Aug 2, 2020

Do you have images that demonstrate this problem, that are able to be added to the test suite under the Pillow license?

@innovara
Copy link
Author

innovara commented Aug 2, 2020

I have recreated those images which you can add to the test suite.

TGA_samples.zip

Thank you.

@radarhere
Copy link
Member

I've created #5396 to fix an unrelated bug mentioned in the StackOverflow answer.
I've created #5400 to fix the reading in of colors.
You would think that would be the end of it, but saving straightaway to PNG (show() uses the PNG format) is actually another problem again, and I think that won't be fixed until we significantly improve ImagePalette.

If #5400 is merged, then the following will work.

from PIL import Image
Image.open('UCM8.TGA').convert("RGB").show()

@radarhere radarhere added the Bug Any unexpected behavior, until confirmed feature. label Apr 16, 2021
@kylefoley76 kylefoley76 mentioned this issue Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants