Convert an Image to Grayscale with ImageMagick

By  on  
Grayscale Logo

A few years ago I bought a DSLR camera with a bunch of filter effects built in and it's been worth every penny.  I took some incredible photos in London, Paris, and Jamaica, and tooks some really special photos of my son during his first few years.  And many of my favorite photos were taken with grayscale filter but some I took in color and badly wanted them in grayscale.  Of course I can use Photoshop to convert the image to grayscale but that's too much work.  I have ImageMagick -- why not use the shell to very quickly convert it to grayscale?

Converting the image to grayscale with ImageMagick is simple:

convert my-image.jpg -colorspace Gray my-image-gray.jpg

The command is self-explanatory and executes in milliseconds.  And since Photoshop takes a few seconds to start and I have to do the work manually, ImageMagick makes everything so much easier.

Recent Features

  • By
    Regular Expressions for the Rest of Us

    Sooner or later you'll run across a regular expression. With their cryptic syntax, confusing documentation and massive learning curve, most developers settle for copying and pasting them from StackOverflow and hoping they work. But what if you could decode regular expressions and harness their power? In...

  • By
    An Interview with Eric Meyer

    Your early CSS books were instrumental in pushing my love for front end technologies. What was it about CSS that you fell in love with and drove you to write about it? At first blush, it was the simplicity of it as compared to the table-and-spacer...

Incredible Demos

Discussion

  1. MaxArt

    How about sepia tones? After all, it’s just like converting to grayscale with a different balance of red, green and blue.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!