Pillow
Pillow copied to clipboard
Prevent opening P TGA images without a palette
Using http://www.paulbourke.net/dataformats/tga/ as the TGA specification, this PR makes two changes
- Tests/images/dilation4.lut has
colormaptypeset 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. - 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.