ImageMagick Cheatsheet
A collection of ImageMagick commands for common image editing tasks.
What is ImageMagick?
Imagemagick is a fanstastic open-source CLI tool used for editing and manipulating digital images. It is written in C and can be used on a variety of operating systems, including Linux, Windows, and macOS
If you’re on MacOS (like me) and already have Homebrew installed on your system, you can easily install the latest binary with brew install imagemagick
Basic Image Operations
Convert an image format
Convert an image from one format to another:
magick input.jpg output.pngResize an image (maintain aspect ratio)
Resizes an image to a specific size while maintaining its aspect ratio:
magick input.jpg -resize 800x600 output.jpgCrop an image
Crop an image to a specific size and position:
magick input.jpg -crop 400x400+50+50 output.jpgRotate an image
Rotate an image by 90 degrees:
magick input.jpg -rotate 90 output.jpgImage Enhancement & Effects
Convert to grayscale
Convert an image to black & white (grayscale):
magick input.jpg -colorspace Gray output.jpgAdjust brightness & contrast
Increase brightness by 10 and contrast by 20:
magick input.jpg -brightness-contrast 10x20 output.jpgBlur an image
Apply a Gaussian blur effect:
magick input.jpg -blur 0x5 output.jpgSharpen an image
Sharpen an image using an Unsharp Mask:
magick input.jpg -unsharp 0x2 output.jpgCompression & Optimization
Reduce file size (JPEG)
Compress a JPEG image by adjusting quality:
magick input.jpg -quality 75 output.jpgConvert & compress to WebP
Convert and optimize an image in WebP format:
magick input.jpg -resize 800x600 -quality 75 output.webpStrip metadata (EXIF data)
Remove all metadata (such as camera details and location info):
magick input.jpg -strip output.jpgTransparency & Layering
Make a specific color transparent
Make all white areas transparent:
magick input.png -transparent white output.pngAdd a watermark
Overlay a watermark image at the bottom-right corner:
magick input.jpg watermark.png -gravity southeast -composite output.jpgText & Graphics
Add text to an image
Overlay text on an image at a specific position:
magick input.jpg -fill white -pointsize 36 -draw "text 50,50 'Hello World'" output.jpgAdd a border
Add a 10-pixel black border to an image:
magick input.jpg -bordercolor black -border 10 output.jpgWorking with Multiple Images
Merge images (side by side)
Horizontally merge two images:
magick convert image1.jpg image2.jpg +append output.jpgCreate an animated GIF
Generate a GIF from multiple images:
magick -delay 50 -loop 0 frame1.jpg frame2.jpg frame3.jpg output.gifExtract frames from a GIF
Extract individual frames from an animated GIF:
magick input.gif -coalesce frame_%03d.pngBatch Processing
Convert all PNGs in a folder to JPG
magick mogrify -format jpg *.pngGenerate thumbnails for all images
Create smaller versions of all images in a folder:
magick mogrify -resize 150x150 *.jpg