Pillow
Pillow copied to clipboard
Add CMYKA Support
What did you do?
Work with CMYK tif images with Alpha (Transparency)
What did you expect to happen?
To work in the same way a RGBA image would.
What actually happened?
Currently fails to load the images
What are your OS, Python and Pillow versions?
- OS: Windows 10
- Python: 3.7
- Pillow: 6.1.0
Attached sample image. Aus_03.zip
Originally reported in https://github.com/python-pillow/Pillow/issues/3984#issuecomment-513617007.
To understand the scope of what you are interested in, after loading, what would like to do with the images? Convert them to another mode? Save them directly as TIFF again? A different operation?
I'm working with a combination of print and screen media, basically what I want to do:
- open a CMYK (no alpha) and convert to CMYKA
- overlay a second CMYKA image (paste operation)
- apply a perspective transform (transform operation)
- save as CMYKA TIFF and also convert to RGBA for saving
Thanks :)
Hello @radarhere, a few days ago I stumbled upon the following keys in a series of tiff files:
('MM', 5, (1,), 1, (8, 8, 8, 8, 8), (1,))
('II', 5, (1,), 1, (8, 8, 8, 8, 8), (1,))
Those keys are not referenced in open_info (/PIL/TiffImagePlugin.py).
They look very similar to (II, 5, (1,), 1, (8, 8, 8, 8, 8), (0,)): ("CMYK", "CMYKX") but i don't know what is the impact of the extraSamples value.
Do you think it would be ok to add those values to the open_info list ?
(II, 5, (1,), 1, (8, 8, 8, 8, 8), (1,)): ("CMYK", "CMYKX"),
(MM, 5, (1,), 1, (8, 8, 8, 8, 8), (1,)): ("CMYK", "CMYKX"),
Relating to the sample image provided by @Gibbz it's a similar problem.
the key for the sample is : ('II', 5, (1,), 1, (8, 8, 8, 8, 8), (2,)) which is also missing in the open_info.
After adding the following keys, pil seems to work as expected.
(II, 5, (1,), 1, (8, 8, 8, 8, 8), (1,)): ("CMYK", "CMYKX"),
(MM, 5, (1,), 1, (8, 8, 8, 8, 8), (1,)): ("CMYK", "CMYKX"),
(II, 5, (1,), 1, (8, 8, 8, 8, 8), (2,)): ("CMYK", "CMYKX"),
(MM, 5, (1,), 1, (8, 8, 8, 8, 8), (2,)): ("CMYK", "CMYKX"),
Comparing further it seems logical to also add :
(II, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (1, 0)): ("CMYK", "CMYKXX"),
(MM, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (1, 0)): ("CMYK", "CMYKXX"),
(II, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (2, 0)): ("CMYK", "CMYKXX"),
(MM, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (2, 0)): ("CMYK", "CMYKXX"),
ExtraSamples describes the state of the alpha - https://www.awaresystems.be/imaging/tiff/tifftags/extrasamples.html. So I would think that the situation from @ioyaeu isn't different from the general request for CMYKA.
Since I stumbled across the same issue of not being able to open cmyk tiff files with an alpha channel - is supporting those planned in the future?