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

Prevent opening P TGA images without a palette #7797

Merged
merged 2 commits into from Mar 11, 2024

Conversation

radarhere
Copy link
Member

Using http://www.paulbourke.net/dataformats/tga/ as the TGA specification, this PR makes two changes

  1. Tests/images/dilation4.lut has colormaptype set to zero, indicating that it does not have a color map. According to "DATA TYPE 1: Color-mapped images" in the spec though, when "Image Type Code" (imagetype) is 1, which it is, then the image is "DATA TYPE 1" and "Color Map Type" should be 1. So this image is actually invalid. This PR will be more flexible though, and just set the image mode to L instead of P, due to the lack of palette.
  2. In the spec, "Color Map Entry Size" is listed as "16 for the Targa 16, 24 for the Targa 24, 32 for the Targa 32." This PR raises an error if it is any other value. I created image for this through modifying p_16.tga by hand.

@radarhere radarhere changed the title Prevent P TGA images without a palette Prevent opening P TGA images without a palette Feb 13, 2024
@hugovk hugovk merged commit d8c8075 into python-pillow:main Mar 11, 2024
56 checks passed
@radarhere radarhere deleted the tga_palette branch March 12, 2024 00:40
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