As far as I can see, PHP-Imagick can't do level-colors. The
Imagick::levelImage fmw42 revers to can only adjust the levels of an image: move or stretch the histogram.
Better try this:
Code: Select all
<?php
$imgUrl = 'image.jpg';
$image = new Imagick($imgUrl);
//make Grayscale image
$image->quantizeImage (256, imagick::COLORSPACE_GRAY, 10, false, false);
//make monotone blue
$image->setImageColorspace(imagick::COLORSPACE_RGB);
$image->colorizeImage ('#1200FF',1);
header('content-type: image/jpg');
echo $image;
?>
I Don't know what the third argument,
int $treedepth of
quantizeImage means; 10 or 10000 gives the same result, so never mind. See
http://nl2.php.net/manual/en/function.i ... eimage.php
Also
$image->setImageColorspace(imagick::COLORSPACE_GRAY) does not work on my local Imagick. Looks like some sort of bug. On my testing server it does work, but it generates a grayscale image that has lot more than 256 colors. That's why I use
imagick::quantizeImage.
(another side track) Testing above script I discovered that
$image->quantizeImage (256, imagick::COLORSPACE_GRAY, 10, false, false); does not affect the original image when it has less than 256 colors (and again it does work as expected on my remote server) ... did I discover a bug?