David A Roberts

Converting images to grayscale in Linux with ImageMagick

To convert a single image 'image.jpg' to a grayscale version 'image-bw.jpg':

convert image.jpg -colorspace Gray image-bw.jpg

To convert an entire directory in images to grayscale:

mkdir bw && for i in *.jpg; do convert $i -colorspace Gray bw/$i; done

The grayscale images will be placed in a subdirectory named 'bw'. To convert something other than JPEGs, just change *.jpg to the appropriate file extension. For more information, see here.


blog comments powered by Disqus

Search

Loading...


Random Quote

Loading...



© 2007–2010 David A Roberts. Valid XHTML & CSS. Entries (RSS) & Comments (RSS). Source code.