In both Kirby CMS 3.5.6 and 3.6 I’ve tested the Thumbnail API to serve images with a srcset pre-defined in the config.php -> thumbs object. The original file through image.jpg delivers an asset similar with the original file with the correct balance of colors. While the ones generated through Thumbnails API image-400x.jpg have a reduced saturation than the original.
I’ve temporarily ignored this problem by increasing the saturation of all images via CSS filter: saturate(1.30); but I don’t like this solution as I would have some original files being delivered resized from the Thumbnails API, and others the original file.
I’ve tried:
Smaller Images
Different Format
Different Thumbs Driver (im, gd)
Interlace on and off
Maybe I’m doing something wrong here, this is an amazing feature by Kirby CMS it works very smoothly and it’s amazingly intuitive, I would just like to see this fixed.
Quiet a big difference imho. For the moment, I’ll use @Rafael_Goncalves trick by pushing saturation with CSS but not satisfied neither by this solution.
I’ve been fiddling with this as well and my conclusion is that it’s only possible to maintain the color profile when using ImageMagick as your thumb driver.
My understanding is Kirby uses GD as it’s default driver and GD does not retain the embedded color profile when converted; so you need to use ImageMagick by specify it in your config.php file as such:
return [
'thumbs' => [
'driver' => 'im'
]
];
Check if ImageMagick is available on host:
I’m on a shared host so I needed to check the host has ImageMagick extension available which I did with a small php script I uploaded to my web host and it looks like this:
<?php
// Check PHP version
echo "PHP Version: " . phpversion() . "<br>";
// Check if the Imagick extension is loaded
if (extension_loaded('imagick')) {
echo "ImageMagick (Imagick extension) is installed.<br>";
// Create an Imagick object to confirm functionality
$imagick = new Imagick();
echo "Imagick version: " . $imagick->getVersion()['versionString'] . "<br>";
} else {
echo "ImageMagick (Imagick extension) is NOT installed.<br>";
}
// Check if the 'convert' command is available in shell
exec("convert -version", $output, $return_var);
if ($return_var === 0) {
echo "ImageMagick CLI is available.<br>";
echo "CLI Version: " . implode("<br>", $output) . "<br>";
} else {
echo "ImageMagick CLI is NOT available.<br>";
}
// Check loaded PHP extensions
echo "<br>Loaded PHP Extensions:<br>";
echo implode(", ", get_loaded_extensions()) . "<br>";
// Check server information
echo "<br>Server Information:<br>";
echo "Server Software: " . $_SERVER['SERVER_SOFTWARE'] . "<br>";
echo "Server Name: " . $_SERVER['SERVER_NAME'] . "<br>";
?>
Once you’ve uploaded it to the server then visit the url and you should see something similar to:
If you are working locally then be sure you have ImageMagick convert installed and also make sure you add the path to convert to Kirby’s config.php file as such:
Conclusion:
Now when I upload webp images with Display P3 color profiles they are retained so while I’ve not checked it on my live server I suspect it will work just as well.
Note that the PHP imagick extension is NOT needed/is not used by Kirby. Kirby uses ImageMagick directly on the command line via exec(), so you require ImageMagick installed on the server and exec() must be enabled.