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('');
$img = new Imagick();


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:

Need Your Help

Sum field by date range

solr sum facet

I'm using solr 3.6 and I'm kinda stuck trying to perform a special query.

How to put an asynctask inside loop

android android-asynctask

Actually what i want to do is run an asynctask inside a loop with different values. So, once the currently running asynctask finishes-it will start the asynctask again with another value and it will