How can I convert an image to grayscale via the command line?

LinuxImageCommand LineSips

Linux Problem Overview


How can I use sips, imagemagic, or another tool to convert an image to black and white (grayscale) via the command line?

Linux Solutions


Solution 1 - Linux

If you have imagemagick installed,

convert source.jpg -colorspace Gray destination.jpg (true grayscale only)
convert source.jpg -monochrome destination.jpg (true black and white)
convert source.jpg -separate destination.jpg (separate into gray channels)

If you don't care about losing the original file: mogrify -colorspace Gray file.

Solution 2 - Linux

use one of: -monochrome or -colorspace gray options for imagemagick (convert).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncwdView Question on Stackoverflow
Solution 1 - LinuxmarkView Answer on Stackoverflow
Solution 2 - LinuximmView Answer on Stackoverflow