2014-08-24
都是按之前的程序进行了,但去年8月均可以用Imagick正常生成CMYK的图片,但今天就是不行。
通过一切测试方法及思路,解决方法以下。php
问题主要出如今: 生成的二维码是RGB格式,须要转换为CMYK,而后在与CMYK的模块进行图片合成。测试
第一: 之前生成的二维码是png格式,位深度为8。通过分析将生成的二维码改成jpg格式,位深度为24.spa
第二:在与模板合成以前,将二维码转换为CMYK格式。而后在与模板合并。orm
private function RGBtoCMYK($source, $save_file, $icc_cmyk, $icc_rgb){ $img_object = new Imagick($source); if ($img_object->getImageColorspace() == 1 OR $img_object->getImageColorspace() == 13) { $profiles = $img_object->getImageProfiles('*', false); $has_icc_profile = (array_search('icc', $profiles) !== false); if ($has_icc_profile === false) { //$icc_cmyk = file_get_contents('./Public/Img/AdobeRGB1998.icc'); $img_object->profileImage('icc', $icc_cmyk); unset($icc_cmyk); } //$icc_rgb = file_get_contents('./Public/Img/USWebUncoated.icc'); $img_object->profileImage('icc', $icc_rgb); unset($icc_rgb); } $image_data = $img_object->getImageGeometry(); $img_object->setImageColorspace(12); $img_object->setImageFormat('jpeg'); $img_object->writeImage($save_file); $img_object->clear(); $img_object->destroy(); return $save_file; }