php imagick 将图像色彩CMKY转RGB
公司某个项目需要抓取pdf的缩略图,最近有部分缩略图无法在IE浏览器显示,但是能够在谷歌浏览器显示。最后发现无法显示的图片图像色彩为CMKY,而CMKY在I E浏览器是无法显示的。所以需要将图像色彩CMKY转为RGB。
关于ICC 文件 提供地址可以下载:
CMYK: http://www.mattbeals.com/icc/profiles/cmyk/USWebUncoated.icc.zip
RGB:http://www.mattbeals.com/icc/profiles/rgb/AdobeRGB1998.icc.zip
$im = new Imagick($filename);
if ($im->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
$i = new Imagick($filename);
$profiles = $i->getImageProfiles('*', false);
$has_icc_profile = (array_search('icc', $profiles) !== false);
if ($has_icc_profile === false) {
$icc_cmyk = file_get_contents('USWebUncoated.icc');
$i->profileImage('icc', $icc_cmyk);
unset($icc_cmyk);
}
$icc_rgb = file_get_contents('AdobeRGB1998.icc');
$i->profileImage('icc', $icc_rgb);
unset($icc_rgb);
$i->writeImage($filename);
}
//该片段来自于http://outofmemory.cn






