Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #8872
Looking at the specification, or even just looking at https://github.com/python-pillow/Pillow/blob/main/Tests/images/hopper.xpm#L50), you will see that an XPM image describes a palette with a series of keys and values, and then lists the pixel values within lines separated by quotes and commas. Our "raw" decoder cannot handle this pixel data, and I've created a Python decoder instead.
I've also pushed commits to read an image as RGB if the palette is larger than 256 colours (test image from the user in the issue), or if the palette keys are longer than a single character (test image created by ImageMagick), removing this error.
Pillow/src/PIL/XpmImagePlugin.py
Lines 59 to 61 in cda26be