Imagemagick desaturate black/white?
Would like to turn this into black and white.. can't figure out what to use from imagick..
$handle_data = file_get_contents('http://www.bungie.net/Stats/Reach/Nightmap.ashx'); //http://www.bungie.net/Stats/Halo3/Nightmap.ashx $img = new Imagick(); $img->readImageBlob($handle_data); $img->writeImage('nightmap/'.$time.'.gif');
Using Imagick::modulateImage could be a quick&dirty solution. Dirty because color theory is a rather complex field, and there can be done more to create grayscale images than just desaturating the image (like applying different weights to the single color channels).
bool Imagick::modulateImage (float $brightness , float $saturation , float $hue)
Given an image, keep brightness and hue at 100%, while setting saturation to 0%. There is an example at the bottom of the documentation page that does exactly that.
There's a much better (and just as simple) solution: $im = $im->fxImage('intensity');
That applies a function to the image, where intensity is equal to 0.299*red+0.587*green+0.114*blue.
That formula is based on how our eyes are more sensitive to different colours, and as such the difference between that and a "flat" grayscale image really is night and day.
More details here: