If you need to convert images that are on CMYK format into RGB and want to preserve colour information, this may be helpful:
<?php
$image = new Imagick("CMYK_image.jpg"); // load image
$profiles = $image->getImageProfiles('*', false); // get profiles
$has_icc_profile = (array_search('icc', $profiles) !== false); // we're interested if ICC profile(s) exist
if ($has_icc_profile === false)
{
// image does not have CMYK ICC profile, we add one
$icc_cmyk = file_get_contents('/path/to/icc/SomeCMYKProfile.icc');
$image->profileImage('icc', $icc_cmyk);
}
// Then we need to add RGB profile
$icc_rgb = file_get_contents('/path/to/icc/SomeRGBProfile.icc');
$image->profileImage('icc', $icc_rgb);
$image->setImageColorSpace(Imagick::COLORSPACE_RGB);
$image->writeImage("RGB_image.jpg");
?>
There may be better and more elegant ways to do this, but hope this helped.
Imagick::profileImage
(No version information available, might be only in CVS)
Imagick::profileImage — 画像のプロファイルを追加あるいは削除する
説明
bool Imagick::profileImage
( string $name
, string $profile
)
警告
この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。
ICC、IPTC あるいは汎用のプロファイルを画像に追加あるいは削除します。 profile が NULL の場合は画像からプロファイルを削除し、 それ以外の場合は追加します。 name に '*'、profile に NULL を指定すると、画像からすべてのプロパティを削除します。
パラメータ
- name
-
- profile
-
返り値
成功した場合に TRUE を返します。
エラー / 例外
エラー時に ImagickException をスローします。
Imagick::profileImage
Eero Niemi (eero at eero dot info)
29-Apr-2008 05:01
29-Apr-2008 05:01
