note 107716 added to imagick.setimagecolorspace
| From: | eth at ethaniel dot com | Date: | Tue, 28 Feb 2012 18:15:11 +0000 |
| Subject: | note 107716 added to imagick.setimagecolorspace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186417@lists.php.net to get a copy of this message | ||
When converting from CMYK to RGB using this function, the image can become inverted. To fix this,
use a workaround (don't forget to download the .icc files online):
// don't use this (it inverts the image)
// $img->setImageColorspace (imagick::COLORSPACE_RGB);
if ($img->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
$profiles = $img->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(dirname(__FILE__).'/USWebUncoated.icc');
$img->profileImage('icc', $icc_cmyk);
unset($icc_cmyk);
}
// then we add an RGB profile
$icc_rgb = file_get_contents(dirname(__FILE__).'/sRGB_v4_ICC_preference.icc');
$img->profileImage('icc', $icc_rgb);
unset($icc_rgb);
}
$img->stripImage (); // this will drop down the size of the image dramatically (removes all
profiles)
----
Server IP: 69.147.83.197
Probable Submitter: 178.140.115.147
----
Manual Page -- http://www.php.net/manual/en/imagick.setimagecolorspace.php
Edit -- https://master.php.net/note/edit/107716
Del: integrated -- https://master.php.net/note/delete/107716/integrated
Del: useless -- https://master.php.net/note/delete/107716/useless
Del: bad code -- https://master.php.net/note/delete/107716/bad+code
Del: spam -- https://master.php.net/note/delete/107716/spam
Del: non-english -- https://master.php.net/note/delete/107716/non-english
Del: in docs -- https://master.php.net/note/delete/107716/in+docs
Del: other reasons-- https://master.php.net/note/delete/107716
Reject -- https://master.php.net/note/reject/107716
Search -- https://master.php.net/manage/user-notes.php