diff --git a/src/app/code/community/Varien/Image/Adapter/Imagemagic.php b/src/app/code/community/Varien/Image/Adapter/Imagemagic.php index bf77b88..2a81756 100644 --- a/src/app/code/community/Varien/Image/Adapter/Imagemagic.php +++ b/src/app/code/community/Varien/Image/Adapter/Imagemagic.php @@ -158,6 +158,24 @@ public function resize($frameWidth = null, $frameHeight = null) } $composite->newimage($frameWidth, $frameHeight, $bgColor); $composite->setimageformat($imagick->getimageformat()); + + if($imagick->getimagecolorspace() == Imagick::COLORSPACE_CMYK) { + $profiles = $imagick->getimageprofiles('*', false); + // we're only interested if ICC profile(s) exist + $has_icc_profile = (array_search('icc', $profiles) !== false); + // if it doesnt have a CMYK ICC profile, we add one + if ($has_icc_profile === false) { + $icc_cmyk = file_get_contents(__DIR__ . '/icc_profiles/USWebUncoated.icc'); + $imagick->profileImage('icc', $icc_cmyk); + unset($icc_cmyk); + } + // then we add an RGB profile + $icc_rgb = file_get_contents(__DIR__ . '/icc_profiles/sRGB.icc'); + $imagick->profileImage('icc', $icc_rgb); + unset($icc_rgb); + $imagick->setimagecolorspace(Imagick::COLORSPACE_SRGB); + } + $composite->setimagecolorspace($imagick->getimagecolorspace()); $dstX = floor(($frameWidth - $imagick->getimagewidth()) / 2); $dstY = floor(($frameHeight - $imagick->getimageheight()) / 2); diff --git a/src/app/code/community/Varien/Image/Adapter/icc_profiles/USWebUncoated.icc b/src/app/code/community/Varien/Image/Adapter/icc_profiles/USWebUncoated.icc new file mode 100644 index 0000000..75efcb2 Binary files /dev/null and b/src/app/code/community/Varien/Image/Adapter/icc_profiles/USWebUncoated.icc differ diff --git a/src/app/code/community/Varien/Image/Adapter/icc_profiles/sRGB.icc b/src/app/code/community/Varien/Image/Adapter/icc_profiles/sRGB.icc new file mode 100644 index 0000000..71e3383 Binary files /dev/null and b/src/app/code/community/Varien/Image/Adapter/icc_profiles/sRGB.icc differ