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;
?>
Imagick::setImageColorspace
(PECL imagick 2.0.0)
Imagick::setImageColorspace — Sets the image colorspace
Description
bool Imagick::setImageColorspace
( int $colorspace
)
Warning
This function is currently not documented; only its argument list is available.
Sets the image colorspace.
Parameters
- colorspace
-
Return Values
Returns TRUE on success.
Errors/Exceptions
Throws ImagickException on error.
Imagick::setImageColorspace
mettedraq at gmail dot com
01-Jul-2010 09:21
01-Jul-2010 09:21
charlie at midsouthhost dot com
07-May-2010 06:45
07-May-2010 06:45
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.
jdstraughan dot com at gmail dot com
26-Sep-2008 09:16
26-Sep-2008 09:16
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
