Colour profiles in php Imagick

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.
Locked
sudoku
Posts: 1
Joined: 2013-04-22T07:11:57-07:00
Authentication code: 6789

Colour profiles in php Imagick

Post by sudoku »

I need to convert various rgb files inte sRGB. As quality matters, I use color profiles.

Until now I use the commandline convert in my PHP script:

Code: Select all

convert 'anyRGBfile.jpg' -profile '$sRGBprofil' 'sRGBfile.jpg'
This works exact in the way I want: If there is a profile in the source file included, the file is correctly converted to srgb. If the source contains no profile, it is treated as if it contained a sRGB-profile.

Now I tried to do the same thing using the Imagick class - without success:

Code: Select all

		
$source='Desert-eci-rgb.jpg';
$sRGBprofil="sRGB_IEC61966-2-1.icc"; 

$image=new Imagick($source);
$profiles = $image->getImageProfiles('*', false); // get profiles
$has_icc_profile = (array_search('icc', $profiles) !== false);

if ($has_icc_profile === false)
{
  // image does not have a ICC profile, we add one
  $icc_in = file_get_contents('$sRGBprofil');
  $image->profileImage('icc', $icc_in);
}

// Destination rgb profile
$icc_out = file_get_contents('$sRGBprofil');
$image->profileImage('icc', $icc_out);

header( "Content-Type: image/jpeg" );
echo $image;
This code works fine, if there is no profile included. Otherwise the iembedded profile is just ignored.
Can anyone give me a hint, please?

Thanks in advance

Locked