downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Imagick::setImageCompose> <Imagick::setImageColormapColor
[edit] Last updated: Fri, 17 May 2013

view this page in

Imagick::setImageColorspace

(PECL imagick 2.0.0)

Imagick::setImageColorspaceSets the image colorspace

Descrierea

bool Imagick::setImageColorspace ( int $colorspace )

Sets the image colorspace.

Parametri

colorspace

One of the COLORSPACE constants

Valorile întoarse

Întoarce TRUE în caz de succes.

Erori/Excepții

Emite ImagickException în caz de eroare.



Imagick::setImageCompose> <Imagick::setImageColormapColor
[edit] Last updated: Fri, 17 May 2013
 
add a note add a note User Contributed Notes Imagick::setImageColorspace - [4 notes]
up
1
eth at ethaniel dot com
1 year ago
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):

<?php
// 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)
?>
up
0
mettedraq at gmail dot com
2 years ago
This is how to Monochrome a jpg [on Windows].. since I couldn't find it anywhere else.

<?php
header
("Content-type: image/jpeg");

$IMagick = new IMagick('c:\\testing\\fruit.jpg');
$IMagick->setImageColorSpace(Imagick::COLORSPACE_GRAY);

echo
$IMagick;
?>
up
0
charlie at midsouthhost dot com
3 years ago
If your getting strange/bad color rendering from a PDF, after trying the colorspace constants noted by jdstraughan, try other values outside that range.

In one case for me only $image->setImageColorSpace(22) provided useful color. I have found posts elsewhere using values up to 255.
up
0
jdstraughan dot com at gmail dot com
4 years ago
FYI, here is the breakdown for (int $colorspace):

Constants:
0 - UndefinedColorspace   
1 - RGBColorspace   
2 - GRAYColorspace   
3 - TransparentColorspace   
4 - OHTAColorspace   
5 - LABColorspace   
6 - XYZColorspace   
7 - YCbCrColorspace   
8 - YCCColorspace   
9 - YIQColorspace   
10 - YPbPrColorspace   
11 - YUVColorspace   
12 - CMYKColorspace   
13 - sRGBColorspace   
14 - HSBColorspace   
15 - HSLColorspace   
16 - HWBColorspace

 
show source | credits | sitemap | contact | advertising | mirror sites