Home >Backend Development >PHP Tutorial >php imagick converts image color CMKY to RGB

php imagick converts image color CMKY to RGB

WBOY
WBOYOriginal
2016-07-25 09:01:231374browse
A project in the company needs to capture PDF thumbnails. Recently, some thumbnails cannot be displayed in IE browser, but they can be displayed in Google Chrome. Finally, it was discovered that the color of the image that could not be displayed was CMKY, and CMKY could not be displayed in the IE browser. Therefore, the image color CMKY needs to be converted to RGB.
About ICC files. The address provided can be downloaded:

CMYK: http://www.mattbeals.com/icc/profiles/cmyk/USWebUncoated.icc.zip
RGB:http://www.mattbeals.com/icc/profiles/rgb/AdobeRGB1998.icc.zip

  1. $im = new Imagick($filename);
  2. if ($im->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
  3. $i = new Imagick($filename);
  4. $profiles = $i ->getImageProfiles('*', false);
  5. $has_icc_profile = (array_search('icc', $profiles) !== false);
  6. if ($has_icc_profile === false) {
  7. $icc_cmyk = file_get_contents(' USWebUncoated.icc');
  8. $i->profileImage('icc', $icc_cmyk);
  9. unset($icc_cmyk);
  10. }
  11. $icc_rgb = file_get_contents('AdobeRGB1998.icc');
  12. $i-> profileImage('icc', $icc_rgb);
  13. unset($icc_rgb);
  14. $i->writeImage($filename);
  15. }
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn