-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
withMetadata() doesn't add sRGB profile to untagged images #734
Comments
As you're probably aware, sharp currently always converts to the sRGB colourspace before generating the output image (be that with or without a profile). #218 is tracking the work to implement more fine-grained control over
This sounds like a possible bug, or at least I don't see an existing unit test for this case, so let me investigate. |
@lovell I don't know if this is quite how you would approach solving the issue (especially as this is my first ever c++ code!), but these changes seem to do the trick; if An alternative solution I tested was adding the following code here: } else if (image.interpretation() == VIPS_INTERPRETATION_sRGB) {
image = image.icc_export(VImage::option()
->set("output_profile", profileMap[VIPS_INTERPRETATION_sRGB].data())
->set("intent", VIPS_INTENT_PERCEPTUAL));
} This also seems to work, and is neater in that it achieves the end result in a single location in the code, but I thought that this was perhaps performing an unccessary conversion computation in addition to attaching the profile. |
Thanks for the update and test case, I agree your first proposed change is a suitable way to fix this for now. I expect the work for #218 will result in a similar change, encapsulating a slightly more complex profile-determining logic before the image output stage is reached and hopefully without too much repetition. |
This is now being tracked at #1323 |
My understanding of the intended behaviour of the
withMetadata()
output method is that it should add an sRGB ICC v2 profile to images that aren't already tagged with their own profile, or otherwise preserve any existing profile. However, using the below code, while images whose source is tagged with an sRGB profile are served with an sRGB profile, images not already tagged with a colour profile don't get one in the output.On a related note, it would be good to have the ability to strip all metadata except colour profile, which I don't think is possible with the current options. One might well wish to get rid of all EXIF/IPTC data for privacy reasons but still tag with an sRGB profile to ensure correct rendering in Chrome (which is the reason for my interest in this - Chrome's annoying failure to treat untagged images as sRGB is causing most images in my web app to display poorly on non-sRGB monitors).
The text was updated successfully, but these errors were encountered: