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
ICC Profile not saved for TIF files #5225
Comments
Hi Crubert-digit, I checked my images color spaces before and after the convert (.jpg and .tif). Both of them shows after the convert that there is a Adobe RGB profile, but only the .jpg shows the correct colors. Does anyone know how to fix this problem? |
Hi GvdBend, Are you opening the profile file with ImageCms.getOpenProfile("AdobeRGB.icm")?? It seems you're trying to convert to Bytes an object which is already Bytes. I use the tobytes() method to convert the profile file to the icc_profile bytes format after opening it with ImageCms. For the TIF files try assigning the profile on the info attribute prior saving it (I'm assuming the profile variable already has the icc profile loaded and it is a Bytes object): image.info['icc_profile'] = profile |
Hi Crubert-digit, Sorry, I'm quite new to Python and I indeed didn't use the "ImageCms.getOpenProfile("AdobeRGB.icm")". Now when I try to use your code it gives me the following error : 'PIL.ImageCms.PyCMSError: cannot open profile file'. My understanding is that I haven't created the AdobeRGB profile yet, as it does not standard exist in Pillow? I've checked the website and tried to read more in to the getOpenProfile and buildTransformFromOpenProfiles, but can't really figure out what to do. Could you please explain to me what you did. Thanks in advance! |
Hi GvdBend, ImageCms.getOpenProfile("AdobeRGB.icm") is opening a file in my path called 'AdobeRGB.icm' which contains the icc profile, so actually the method is: |
Hi Crubert-digit, Thanks to you I made it work, thank you! |
This is confusing - I presume you meant to write "result_cv2_to_pil_tif.png" in your code example. |
I've created #5321 to resolve this. |
When loading an image from an array(image opened with cv2, skimage, etc.) and then saving it in .tif format, the icc_profile is not saved. For example:
However, when doing the same for a ".png" file the icc_profile is saved
I solved it adding the icc_profile to the info attribute prior saving the image:
It seems a bug in the save method when the file format is .tif, as it not considers adding the icc_profile to the output image if it was not previously in the info attribute.
I haven't tested it with other file formats.
The text was updated successfully, but these errors were encountered: