Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open CMYK tiff image with spot channels #2821

Closed
genequ opened this issue Nov 1, 2017 · 9 comments
Closed

Can't open CMYK tiff image with spot channels #2821

genequ opened this issue Nov 1, 2017 · 9 comments

Comments

@genequ
Copy link

genequ commented Nov 1, 2017

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!

@hugovk hugovk added the TIFF label Nov 1, 2017
@wiredfool
Copy link
Member

We're currently not able to open files with more than 4 channels.

@wiredfool wiredfool added Enhancement and removed TIFF labels Nov 1, 2017
@homm
Copy link
Member

homm commented Dec 10, 2017

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?

@wiredfool
Copy link
Member

@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.

@homm
Copy link
Member

homm commented Dec 11, 2017

@wiredfool Interesting idea. How we can provide access to additional channels? Via image.info?

@genequ
Copy link
Author

genequ commented Dec 18, 2017

@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 promising

@homm
Copy link
Member

homm commented Jan 7, 2018

Hi! 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 ExtraSamples marker 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,).

@homm
Copy link
Member

homm commented Jan 7, 2018

@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?

@genequ
Copy link
Author

genequ commented Jan 8, 2018

@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.

@radarhere
Copy link
Member

#2938 was merged. Closing in favour of the tracking issue, #1888

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants