Repository navigation
Can't open CMYK tiff image with spot channels #2821
Description
Activity
We're currently not able to open files with more than 4 channels.
I also have requests for such files from our users and the only solution I see without rewriting most parts of Pillow is on-the-fly conversion to RGBA.
@genequ Will you be satisfied with such solution?
@homm I wonder if we could figure out a way to spilt extra channels out as additional bands in the image structure, so that we'd have our usual optimized set of pixels, and spot channels like this would essentially be extra single band images.
@wiredfool Interesting idea. How we can provide access to additional channels? Via image.info?
@homm it is common a file with several spot channels in the prepress industry(mostly generated by Adobe's product). I do not know if it is a good idea to convert to RGBA.
@wiredfool that sounds promisingHi! I've created the fix #2938 which allows opening some TIFFs with ExtraSamples. The problem is that that fix also allows opening your sample TIFF while shouldn't. Some more explanation:
TIFF files contain
ExtraSamplesmarker which tells how to interpret extra channels. According to the docs, it could have three values:EXTRASAMPLE_UNSPECIFIED = 0; EXTRASAMPLE_ASSOCALPHA = 1; EXTRASAMPLE_UNASSALPHA = 2;The sample file has the following value:
tag: ExtraSamples (338) - type: short (3) - value: (0,)
This means that additional channel in the file contains some service information. So I suppose that it is legal to open the file and discard that channel if we don't know what to do with it. On the other hand, macOS's Preview and Windows's 7 Photo viewer treats that channel as the alpha channel. But InfanView and Paint.NET don't.
It is more likely that the file should have ExtraSamples (1,).
@genequ Oh, I'm sorry, just noticed that you never claim that this is alpha channel. So, does discarding the extra channel is better than rejecting the entire image for you?
@homm, thanks a lot for your effect!
Do you mean the value (0) for ExtraSamples is invalid in the sample file? It is created by Adobe Photoshop anyway.
Discarding the spot channels does not actually solve my problem since those channels always contain real contents.
The provided sample file has 5 channels, CMYK + PMS 200 C. When i am trying to open it using
Image.open(), it reports: IOError: cannot identify image file '/Users/gequ/Desktop/cmyk.tif'
cmyk.tif.zip
Thanks for taking care of this!