Images colorspace conversion to sRGB #210
Comments
I agree that we should leave sRGB conversion as late as possible. Aside from the extra complexity of doing this work on upload, unless I misunderstand it is a data-losing operation that I don't think we should apply to original images. When reviewing the the easy-thumbnails library for inspiration for the IIIF Image API I learned that thumbnails generated for colour images (not black-and-white) are automatically converted by this library into the RGB colourspace. I applied the same approach for the IIIF Image API, see https://github.com/ic-labs/django-icekit/blob/develop/icekit/plugins/iiif/views.py#L202 So in short, the RGB conversion is already being done when needed while leaving the original images intact. I don't think we need to change this approach. Unless, that is, the glamkit-imagetools does more sophisticated colour space conversion that the basic approach linked above? |
@jmurty yep I think there's a subtlety here - I used 'colour space' to mean 'colour profile'. Converting (from CMYK) to RGB colourspace isn't the same as converting the embedded colour profile to sRGB, a specific standard defined for consumer monitors. Last I checked (in SFMOMA), EasyThumbnails doesn't do any colour profile conversion, it just strips it in the output to reduce filesize. It seems to me sRGB profile conversion should be a default of easy-thumbnails (perhaps there is a ticket about it over there?) but it wasn't at SFMOMA time. |
NOTE: The conversion performed by icekit-imagetools is more sophisticated than the basic RGB colourspace conversion we are already doing. See https://github.com/ixc/icekit-imagetools/blob/develop/imagetools/utils/srgb.py |
On a quick look through the list, this is the only relevant easy-thumbs ticket (ie converting to sRGB would solve this): |
Looking at the above, to do full sRGB colour profile conversion (or just retention) we will need to:
|
easy-thumbnails doesn't do color profile conversion by default, unless it's started doing it since we built SFMOMA. I propose that we add a (There's also this simpler approach from DrMeers: https://stackoverflow.com/questions/11041044/convert-jpg-from-adobergb-to-srgb-using-pil, but it may only work with Adobe RGB source profiles, not arbitrary profiles). |
Here are 4 examples to illustrate, from https://www.sfmoma.org/artwork/2005.102 . If the file is created with Adobe sRGB the colour looks flat if the profile is stripped (as easy-thumbnails will do) or even if it isn't stripped and viewed on mobile (as mobile devices ignore colour profile). Converting the file to sRGB results in minimal difference on consumer screens if the profile is stripped or ignored. with Adobe RGB (looks flat on mobile devices) Adobe RGB, profile stripped (looks flat) |
I have made an easythumbnails image processor based on the util above that converts an image to sRGB colour profile and RGB colour space so that there is the minimum of visual disruption when the colour profile is dropped. Add it to the beginning of THUMBNAIL_PROCESSORS as per https://easy-thumbnails.readthedocs.io/en/latest/ref/processors/#custom-processors. https://gist.github.com/cogat/fbdfeb099564ef0cdda8491b0d65557c I think this can replace the default colorspace processor. |
glamkit-imagetools
has a function which converts a given image to the sRGB color space, meaning that images with a different color space can be converted and don't appear too different when the profile is stripped for e.g. thumbnails and IIIF operations.The question is, when is the right time to do the sRGB conversion? My instinctive answer is: upon thumbnail creation, rather than on upload.
So, let's do that, unless there's a compelling reason to convert the original uploaded image.
The text was updated successfully, but these errors were encountered: