getkirby-v2 / toolkit

This is the deprecated toolkit for Kirby v2.
http://getkirby.com
81 stars 50 forks source link

Color profiles are removed when creating thumbs #227

Closed olach closed 3 years ago

olach commented 7 years ago

I just realized that the thumb function removes any color profiles embedded in an image.

This is a bad thing. The browser thinks that a missing color profile just means sRGB. That means, that a vivid image that is using the AdobeRGB color space looks slightly faded when a thumb is created, and interpreted using sRGB in the browser.

For the ImageMagick driver, the command -strip is responsible for removal of color profiles: https://github.com/getkirby/toolkit/blob/79a1b171cbbf7200a9c9cee917f17034845c8138/lib/thumb.php#L281

I don't know the best way to handle this. The reason to remove the profiles is to make the images smaller, which is a good thing, but not if it degrades the images.

One suggestion could be to still delete the profile, but first convert the image to sRGB (Browsers uses the sRGB color profile if a profile is not embedded in the image). At least ImageMagick has the option to convert between color spaces. http://www.imagemagick.org/Usage/formats/#color_profile

Another option would be to keep the embedded color profile in the image. The filesize will be slightly larger, but the image quality would be better. Modern computer screens are getting better and better. Most new macs have a larger color gamut that would benefit from keeping the color profiles.

Maybe the best option would be to make this a config setting? I.e: c::set('thumbs.color-profiles', true);

nblackburn commented 7 years ago

You would need to expose a option in thumb.php and pass it from areas that has access to the kirby config.

nblackburn commented 7 years ago

I have added a flag to disable strip, it just needs hooking up to the config and passing along to the instance.

jolantis commented 7 years ago

I made a pull request for a comparable option: https://github.com/getkirby/kirby/pull/518