sRGB to AdobeRGB1998 keep colors

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
jeffreyg
Posts: 14
Joined: 2014-02-10T03:42:50-07:00
Authentication code: 6789

sRGB to AdobeRGB1998 keep colors

Post by jeffreyg » 2015-03-04T06:07:34-07:00

Hello,

We have a system where the user uploads an image and it automaticly sets a sRGB color profile to the image. When I try to convert these images with Imagick to AdobeRGB1998, the colors are different. It has the correct colorprofile but the original colors are gone.

I tried repoducing these steps in Photoshop. When I assign the AdobeRGB1998 color profile to the image, the output is the same as the output of my script. When I convert the image to AdobeRGB1998 color profile, the output is the same as the orignal.

In other words I need my Imagick script to convert the color profile, instead of asigne the color profile.

Here is my code:

Code: Select all

$img->setResourceLimit(6, 4);
$img->stripImage();
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$img->setResolution($cDPI,$cDPI);
$img->resampleImage($cDPI,$cDPI, imagick::FILTER_UNDEFINED,1.5);
$img->profileImage('icc', $icc_adobeRGB);
$img->resizeImage($cWidth,$cHeight,imagick::FILTER_LANCZOS,TRUE);
$img->writeImage($input);
$img->destroy();
Here are the images. I want my Imagick to get the same output as the original image and converted photoshop image with Adobe1998 color profile:

Orignal image wih sRGB color profile
Image

Image generated with my Imagick script with AdobeRGB1998 color profile
Image

Image generated with photoshop assign AdobeRGB1998 color profile
Image

Image generated with photoshop convert to AdobeRGB1998 color profile
Image

snibgo
Posts: 11445
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: sRGB to AdobeRGB1998 keep colors

Post by snibgo » 2015-03-04T06:28:10-07:00

Code: Select all

$img->stripImage();
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$img->setResolution($cDPI,$cDPI);
$img->resampleImage($cDPI,$cDPI, imagick::FILTER_UNDEFINED,1.5);
$img->profileImage('icc', $icc_adobeRGB);
You strip the image, which removes the embedded profile. So profileImage will assign AdobeRGB. If you hadn't stripped, it would have the sRGB profile embedded, so profileImage would convert it.


EDIT: I've just noticed your query is about IMagick. My reply wrongly assumed ImageMagick. IMagick might be different.
snibgo's IM pages: im.snibgo.com

jeffreyg
Posts: 14
Joined: 2014-02-10T03:42:50-07:00
Authentication code: 6789

Re: sRGB to AdobeRGB1998 keep colors

Post by jeffreyg » 2015-03-05T00:37:19-07:00

Hello snibgo,

Thank you for the reply. I had to use strip to change the DPI of the image and the size of the image. Couldn't get it working in any other way. I added the sRGB profile first, because you were right that it strips the image profile.

Code: Select all

$img->stripImage();
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$img->setResolution($cDPI,$cDPI);
$img->resampleImage($cDPI,$cDPI, imagick::FILTER_UNDEFINED,1.5);
$img->profileImage('icc', $icc_sRGB);
$img->profileImage('icc', $icc_adobeRGB);
Now it works and the colors are exactly the same.

Post Reply