Page 1 of 1

How To Create a Monotone Image?...

Posted: 2010-12-02T08:01:18-07:00
by ok200
Image

Hi Everyone,

I am trying to create the effect as showed in the attached example.

In photoshop this effect works like this:
source image RGB
image mode = grayscale
image mode = duotone / monotone
All gray and black tones are replaced by the color you choose.

Anyone?

Thanks

Re: How To Create a Monotone Image?...

Posted: 2010-12-02T10:45:25-07:00
by fmw42
In command line you would use +level-color blue-white

convert grayscaleimage +level-color blue-white result

see http://www.imagemagick.org/Usage/color/#level-colors

But I don't know if Imagick can do +level-color? see http://us3.php.net/manual/en/function.i ... limage.php

You could also try -tint or create your own color gradient and apply it via -clut or duotone effect

see http://www.imagemagick.org/Usage/color/#duotone and http://www.imagemagick.org/Usage/color/#clut

Re: How To Create a Monotone Image?...

Posted: 2010-12-22T14:18:59-07:00
by hampleman
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?

Re: How To Create a Monotone Image?...

Posted: 2010-12-22T18:41:24-07:00
by fmw42

Re: How To Create a Monotone Image?...

Posted: 2010-12-23T01:49:07-07:00
by ok200
thanks everyone!
clut-image seems to do the best job.