-
Notifications
You must be signed in to change notification settings - Fork 53
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
Faulty color profile conversion #114
Comments
Reading this issue on stackoverflow, it seems to be that Willow is using its default setting to convert to a generic "RGB" profile. Pillow can read and save icc_profiles, see code below. original_img = PIL.open(image)
original_icc_profile = img.info.get("icc_profile")
# not sure how to convert this, maybe:
rendition_icc_profile = PIL.ImageCms.createProfile('sRGB')
rendition_img = PIL.ImageCms.profileToProfile(original_img, original_icc_profile, rendition_icc_profile)
rendition_img.save(d, "JPEG", icc_profile=rendition_icc_profile) |
@andre-fuchs thanks for filing this. I've transferred the issue to Willow, which is the library Wagtail uses for image manipulation. #63 is related and we need to restart work on it. |
Please do! I would propose to not just keep the color profile, but to define a setting if images should be converted to a specific color profile or not. This could be a simple Boolean variable |
Is there any progress on this? I could probably fix this myself if somebody points me to the piece of code that needs to be updated. |
@andre-fuchs alas, this slipped under the mountain of other things to look at. |
ICC color profile and EXIF data implemented!Following #63 by @stefanistrate, I implemented two methods to add the ICC color profile and the EXIF data that are applied in the save methods of the Pillow plugin. Here is my fork. I tested it manually with an instance of Wagtail v5.2. Color profile take-over does work as expected for JPEG, PNG, WebP and AVIF. How do I get these tests running?I did not manage to figure out how to run the unit tests. Could somebody walk me through, please. I just want to be able to test my code locally. With my manual test setup I created a few unnecessary/messy commits. But it seems to do the job finally. I would like to add more tests here and add another feature. But first, please help me to get these tests running. You can try it yourself. Here are the requirements. Just make sure to remove the standard Willow package before installing via PIP.
Here is a screenshot of my manual tests. sRGB.icc on the left and ECI_RGB_v2.icc on the right. All files generated by Wagtrail with ICC profiles included. Colors do look consistent now. (Photo from Wikipedia) |
@andre-fuchs locally,
|
Thanks! This was exactly what I needed. I will add more tests and try to wrap this up today. |
Issue Summary
Photo files with an AdobeRGB color profile are not correctly converted. The result looks less saturated. The resulting images (JPG and WebP format) use a color profile, named "RGB". If I upload the source files with an "sRGB" profile, the results match.
Is there a setting to tell Pillow how to convert these color spaces/profiles? "Relative colorimetric" should be the way to go, I think. I would love to see a setting to configure this properly. "sRGB" could always be the color space for the converted images. But I would love to see more perceptually true results from other color spaces as well. Many users do not know about these technical details at all.
Many other websites seem to handle this better, like you can see on the right image in the screenshot.
The difference seems to be more emphasized in Safari on Mac OS. But also in Firefox on Linux I was seeing the difference.
Technical details
Left: Original JPG with AdobeRGB color profile
Middle: Wagtail rendition
Right: Rendition of contemporaryartdaily.com for comparison
The text was updated successfully, but these errors were encountered: