Search code examples
imageimagemagickimagemagick-convert

Convert entire folder to greyscale using image magick?


I am trying to convert an entire folder to grayscale, using image magick.

convert *.jpg -colorspace Gray -separate -average

is met with this error :

convert:  `-average' @ error/convert.c/ConvertImageCommand/3290.

What is the correct command for this?


Solution

  • If you have lots of files to process, use mogrify:

    magick mogrify -colorspace gray *.jpg
    

    If you have tens of thousands of images and a multi-core CPU, you can get them all done in parallel with GNU Parallel:

    parallel -X magick mogrify -colorspace gray ::: *.jpg