Convert RGB to Grayscale in ImageMagick command-line

grayscaleimagemagick

How do I convert a RGB image (3 channels) to a grayscale one, using the (r+g+b)/3 method?
I look through an examples page: http://www.imagemagick.org/Usage/color_mods/#grayscale
but the desired method:

convert test.png -fx '(r+g+b)/3' gray_fx_average.png

gave me a wrong result – the resulted image has still 3 channels.

You can check this by running a command: identify -format "%[colorspace] <== %f\n" *.png.

Best Answer

convert <img_in> -set colorspace Gray -separate -average <img_out> gives the best result for any image for me.

Related Topic