How Can I Use Imagick to Change the Color Profile to SRGB and Have it Preserve Colors Like `convert {file} -profile {iccfile} {file}

Viewed 258

I'm having an issue converting the color profile from "Display P3" to "sRGB IEC61966-2.1" in Imagick (PHP API Class), and having it preserve the colors of an image the same way it does when running from command line: convert IMG_1329.jpg -profile sRGB2014.icc testimage.jpg

<?php

header('Content-type: image/jpeg');

$sRGB_icc = file_get_contents('sRGB2014.icc');
$image = new \Imagick('IMG_1329.jpg');
$image->setImageProfile('icc', $sRGB_icc);
$image->transformImageColorspace(\Imagick::COLORSPACE_SRGB);

echo $image;

The original image can be downloaded here: http://cdn.webplant.media/IMG_1329.jpg

The ICC Color profile used can be downloaded here: http://cdn.webplant.media/sRGB2014.icc

Here is a screenshot of the different outputs. Notice the vibrant colors in the roof and on the trunk of the tree in the original image, and the image converted with convert.

Original vs Imagick vs Convert

How can I get Imagick to output the same quality image as when using convert IMG_1329.jpg -profile sRGB2014.icc testimage.jpg?

0 Answers
Related