Setting RGB Profile for tif file created by tifffile using Python

125 Views Asked by At

A few months ago, I came here in need to join two files in one layered file. This is the original post.

The solution came from cgohlke's tifffile and it has been working wonders. I got it into a loop to read the files from a folder, find the pairs and do Mr. Gohlke's magic and some minor tweaks.

Now Photoshop is complaining that the files "does not have an embedded RGB profile" and I have to manually set it to AdobeRGB. Which is ok since most of the time I actually do open them all on photoshop to finish the files. But I wanted to get it out of Tifffile ready, if possible.

I decided to go a get a better understanding of tifffile's inner thingys and I also had to study a bit PSDtags so that I could try and understand what was happening.

Reading through the documentation, I found between lines 237 and 241 of tifffile.py:

Tifffile supports a subset of the TIFF6 specification, mainly 8, 16, 32, and
64-bit integer, 16, 32 and 64-bit float, grayscale and multi-sample images.
Specifically, CCITT and OJPEG compression, chroma subsampling without JPEG
compression, color space transformations, samples with differing types, or
IPTC, ICC, and XMP metadata are not implemented.

I do believe that what I need to change is ICC Profile, although it's not implemented apparently.

I did a search and PIL does have a module for that which is ImageCms, but it does not have Adobe RGB support. It returns an error PIL.ImageCms.PyCMSError: Color space not supported for on-the-fly profile creation (AdobeRGB)

So, I'm back and in need to convert an untagged layered tif file to AdobeRGB(1998) (ICC) profile. Anyone know a way I could do that in python?

I can do an Automate through Photoshop, so it doesn't make much sense doing this any other software other than the python script that is creating this file. Otherwise, it's easier for me to just do it in Photoshop anyways.

0

There are 0 best solutions below