Fix reading RGB and CMYK IPTC images #9088
Merged
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.
When opening IPTC images at the moment,
self._modemight be set to a single channel from RGB or CMYK.Pillow/src/PIL/IptcImagePlugin.py
Lines 109 to 112 in d80cf0e
That's incorrect, as we don't have R, G, B, C, M, Y or K modes. Your first instinct might be to say that these should be the rawmode instead, but IptcImagePlugin just passes the image data on to be opened by another plugin. Instead, this PR uses
Image.merge()to combine the image with empty bands for the other channels, to make up the full mode.I've also made some simplifications.
Pillow/src/PIL/IptcImagePlugin.py
Lines 37 to 38 in 7b1ba29
codecis always "iptc", so we don't have to check it.Pillow/src/PIL/IptcImagePlugin.py
Lines 127 to 131 in d80cf0e