Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Prevent opening P TGA images without a palette

Open radarhere opened this issue 1 year ago • 0 comments

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 avatar Feb 13 '24 20:02 radarhere