I'm trying to convert an image to black and white by altering the colorspace with this code:
$im = new Imagick('image.png');
$im->setImageColorspace(Imagick::COLORSPACE_GRAY);
$im->writeImage('out.png');
However after this code, there is no visible change to the image (out.png and image.png look indistinguishable). Any thoughts on why this might be? Is this the proper method to convert and image to B&W? Are there any other methods?
I've also tried setColorspace(Imagick::COLORSPACE_GRAY); with the same results.
Here's the software I'm using:
ImageMagick 6.6.9-7
PHP 5.3.10-1ubuntu3.1
Server version: Apache/2.2.22 (Ubuntu)
Edit: Some extra info
I've also tried converting to other colorspaces (specifically CMY and CMYK) and noticed no visual difference then either.
As an alternative, you can try $im->modulateImage(100,0,100); instead of setImageColorspace()
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With