The fastest way to convert an image to grayscale from the command line is one ImageMagick command:
magick photo.jpg -colorspace Gray photo-gray.jpgThat reads photo.jpg, drops the color, and writes photo-gray.jpg. It works on JPEG, PNG, TIFF, WebP, and anything else ImageMagick can decode, and the output format follows the extension you give the second file. That is the whole job for most people. The rest of this page is the detail behind it: why Gray and not GRAY, how to batch a folder safely, sepia, and the built-in macOS option when you do not want to install anything.
Use magick, not convert
If you have seen older tutorials run convert photo.jpg -colorspace Gray out.jpg, that is ImageMagick 6 syntax. On ImageMagick 7 (the current line) the single entry point is magick, and the bare convert command is deprecated: it still runs as a compatibility shim but prints a deprecation warning, and it can collide with the Windows convert.exe (the disk-format utility) on PATH. Everywhere below uses magick. The other legacy tools are now subcommands: magick identify, magick mogrify, magick montage. Check your version with:
magick -versionIf magick is not found you are on IM6 or it is not installed: brew install imagemagick on macOS, sudo apt install imagemagick on Debian/Ubuntu, winget install ImageMagick.ImageMagick on Windows.
Perceptual gray vs linear gray
-colorspace Gray is the one you almost always want. It produces a perceptual (nonlinear, gamma-encoded) grayscale, the kind your eye expects, where a mid green looks brighter than a mid blue. The official command-line docs give its formula as Gray = 0.212656*R+0.715158*G+0.072186*B, the Rec.709 weighting applied to the gamma-encoded channels. That is exactly the same math as the -grayscale Rec709Luma operator (the primed R'G'B', nonlinear form), so the two are interchangeable.
There is a second, subtly different result you may run into:
# Linear-light grayscale: weights computed in linear RGB, not gamma-encoded
magick photo.jpg -colorspace LinearGray photo-gray.jpg-colorspace LinearGray computes the gray value in linear light before re-encoding. Note that it does not use the same coefficients as Gray: the docs give it as LinearGray = 0.298839*R+0.586811*G+0.114350*B, which are the Rec.601 weights, so the closest -grayscale operator equivalent is Rec601Luminance (linear), not Rec709. Computing in linear light is more physically correct for compositing math, but on a normal photo it usually comes out noticeably darker and flatter than -colorspace Gray, which surprises people. Casing is not a switch: -colorspace gray and -colorspace Gray are the same colorspace, and the meaningful distinction is the word, not the capitals: Gray (Rec.709, nonlinear) vs LinearGray (Rec.601, linear), and on the -grayscale operator Luma (nonlinear) vs Luminance (linear). For a photo you want to look at, stick with -colorspace Gray.
Batch a whole folder with mogrify
To grayscale every JPEG in a directory at once, use magick mogrify. The catch is the entire reason to read this section: mogrify overwrites the files in place. There is no separate output file. Point it at your originals and the originals are gone.
So copy first, then convert the copies:
mkdir gray
cp *.jpg gray/
magick mogrify -colorspace Gray gray/*.jpgIf you want grayscale copies in a different format and to keep the originals untouched, -format writes new files instead of overwriting (it changes the suffix, so the source stays put):
# Writes gray *.png copies next to the *.jpg originals, originals untouched
magick mogrify -format png -colorspace Gray *.jpgThat is the safe batch pattern: -format when you want the originals kept, a copied directory when you genuinely want grayscale files in the same format.
Sepia and true black-and-white
Grayscale is not the only "make it old" effect. For a warm sepia tone, -sepia-tone takes a threshold as a percentage (the docs allow up to 99.9%); around 80% is a typical look:
magick photo.jpg -sepia-tone 80% photo-sepia.jpgAnd "grayscale" is not the same as true 1-bit black and white. Grayscale keeps the full range of grays; a hard black-and-white image has only two values. Threshold the grayscale to get that:
magick photo.jpg -colorspace Gray -threshold 50% photo-bw.pngLower the percentage to keep more black, raise it to keep more white. That is the right tool for line art or a scanned document, not for a photo you want to keep tonal detail in.
macOS: grayscale with sips, no install
Every Mac ships with sips (Scriptable Image Processing System), so if ImageMagick is not installed and you only need a quick grayscale, you do not have to install anything:
sips -s format jpeg --matchTo /System/Library/ColorSync/Profiles/Generic\ Gray\ Profile.icc photo.jpg --out photo-gray.jpgsips is more limited than ImageMagick (it converts grayscale by matching to the system Generic Gray ICC profile rather than offering a choice of luminance methods), but it is genuinely zero-install on macOS and fine for one-off jobs. For anything batch or precise, ImageMagick is the better tool.
See also
- Convert a video to black and white (grayscale) with ffmpeg: the same effect for video, where
hue=s=0desaturates andformat=grayencodes true single-channel gray. - Get image dimensions from the command line:
magick identifyand the macOSsipsroute for reading width and height. - The ffmpeg command cheat sheet: the wider reference for converting, cropping, trimming, and compressing media from the CLI.
Sources
Authoritative references this article was fact-checked against.
- ImageMagick: color modifications (official usage docs)imagemagick.org
- ImageMagick: command-line options (official docs)imagemagick.org
- ImageMagick: porting to version 7 (official docs)imagemagick.org
- ImageMagick: mogrify command-line tool (official docs)imagemagick.org





