Want to improve this cheat sheet? See the Contributing section!
- Why ImageMagick
- Prerequisites
- Installation
- Basic Commands
- Format Conversion
- Resizing and Transformations
- Color Adjustments
- Image Composition
- Text and Annotations
- Special Effects
- Batch Processing
- Animation and GIFs
- Image Analysis
- Advanced Operations
- Best Practices
- Tips
- Troubleshooting
- Contributing
- References
Use ImageMagick® to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, HEIC, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
The functionality of ImageMagick is typically utilized from the command-line or you can use the features from programs written in your favorite language. Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), JuliaIO (Julia), L-Magick (Lisp), Lua (LuaJIT), NMagick (Neko/haXe), Magick.NET (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), magick (R), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images dynamically and automagically.
Understanding color spaces like RGB, CMYK, sRGB is helpful when working with ImageMagick.
Basic knowledge of image processing concepts helps when using the more advanced features.
Familiarity with different image formats and their properties.
apt-get install imagemagick
yum install imagemagick
brew install imagemagick
For memory-related issues: https://github.com/google/sanitizers/wiki/AddressSanitizer
convert -version
identify -list all
convert logo: logo.png
mogrify -background black -format png -depth 8 *.tiff
mogrify -background black -format png -depth 8 *.svg
mogrify -format jpg *.JPG
convert input.webp output.jpg
mogrify -format jpg *.webp
convert *.DCM output.jpg
convert *.jpg document.pdf
convert -density 300 document.pdf page%03d.jpg
note: PDF to Images (One Per Page) The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert"
convert input.png -quality 92 -sampling-factor 4:2:0 output.jpg
mogrify -resize 50% *.png
mogrify -resize 750x750\! *.jpg
convert input.jpg -thumbnail 150x150 thumbnail.jpg
mogrify -rotate 90 *.jpg
convert input.jpg -flip output.jpg
convert input.jpg -flop output.jpg
convert input.jpg -border 10 -bordercolor black output.jpg
convert input.jpg -crop 300x200+50+50 output.jpg
convert -crop 512x512 +repage large.tif tiles/image_%d.tif
# Requires additional scripts
# See: http://www.fmwconcepts.com/imagemagick/rotate3D/index.php
convert input.jpg -colorspace Gray output.jpg
for file in *.png; do convert $file -colorspace Gray $file; done
mogrify -type TrueColorMatte -define png:color-type=6 *.png
convert input.tif -colorspace RGB output.tif
convert input.jpg -profile sRGB.icc -profile AdobeRGB.icc output.jpg
convert input.jpg -brightness-contrast 10x15 output.jpg
convert input.jpg -negate negative.jpg
convert input.jpg -transparent white output.png
convert input.jpg -sepia-tone 80% sepia-output.jpg
convert *.jpg +append horizontally_appended.jpg
convert *.jpg -append vertically_appended.jpg
montage *.jpg -geometry 200x200+5+5 -background lightblue montage.jpg
composite -gravity center overlay.png base.jpg output.jpg
convert before.jpg after.jpg +append comparison.jpg
convert input.jpg -fill white -pointsize 24 -gravity southeast -annotate +10+10 'Copyright 2025' output.jpg
convert input.jpg -gravity southeast -stroke '#FFFFFF' -strokewidth 2 -annotate +5+5 'Watermark' -stroke none -fill '#FFFFFF88' -annotate +5+5 'Watermark' output.jpg
convert input.jpg -blur 0x8 blurred-output.jpg
convert input.jpg -vignette 0x20 vignette.jpg
convert input.jpg -charcoal 2 sketch.jpg
convert input.jpg -bordercolor white -border 10 -background black -rotate 6 -background white -polaroid 10 polaroid.jpg
# Requires additional scripts
# See: http://www.fmwconcepts.com/imagemagick/fisheye2rect/index.php
mogrify -format jpg *.png
mogrify -resize 800x600 -quality 85 *.jpg
for file in *.jpg; do
convert "$file" -resize 1024x768 -fill white -pointsize 20 -gravity southeast \
-annotate +10+10 'Copyright 2025' "watermarked_$file"
done
for filename in *.png; do mv "$filename" "prefix_$filename"; done
for f in *.jpg; do mv "$f" "$(echo "$f" | sed s/IMG/VACATION/)"; done
convert -resize 100% -strip -quality 90 input.jpg output.jpg
convert -resize 100% -transparent -strip -quality 90 input.png output.png
convert -delay 20 -loop 0 frame*.jpg animated.gif
convert animated.gif -coalesce frame%03d.png
convert input.gif -layers optimize optimized.gif
convert input.gif -coalesce -resize 50% -layers optimize output.gif
identify image.jpg
identify -format '%w X %h %[channels] %[bit-depth] %x x %y\n' input.jpeg
identify -verbose image.jpg
convert image.jpg -format "%[mean] %[standard-deviation]" info:
convert image.jpg -define histogram:unique-colors=true histogram:info:
find ./ -type f -name '*.svg' | xargs -I{} sed -i_old -n -e 's/polygon fill="none"/polygon fill="white"/g;p;' {}
mogrify -define jpeg:extent=5100kb *.png
montage -geometry 200x200+5+5 -background lightblue *.jpg mosaic.jpg
- Use GraphicsMagick for faster processing when applicable
- Use appropriate colorspace for your target medium
- Be mindful of memory usage for large images
- Set appropriate quality when saving to lossy formats
- Use
-strip
to remove metadata and reduce file size - When working with transparency, use PNG rather than JPG
- For complex scripts, consider using ImageMagick with shell scripting
- Use
mogrify
for in-place edits andconvert
for creating new files
- For font configuration warnings: https://stackoverflow.com/questions/24712158/how-to-solve-imagemagicks-fontconfig-warning-ignoring-utf-8-not-a-valid-regi
- Check permissions for output directories
- Verify that your ImageMagick installation has the required delegates for specific formats
- If processing fails, try increasing memory limits in policy.xml
Here's how to contribute to this cheat sheet:
- Fork the repository
- Open README.md
- Make your changes
- Submit a pull request
Your contributions will be greatly appreciated!
- Official Website: http://www.imagemagick.org/script/index.php
- Command-Line Options: http://www.imagemagick.org/script/command-line-options.php
- Fred's ImageMagick Scripts: http://www.fmwconcepts.com/imagemagick/
- GraphicsMagick: http://www.graphicsmagick.org/formats.html
- Legacy Forum: https://legacy.imagemagick.org/discourse-server/
- Crop & Tile Examples: https://legacy.imagemagick.org/Usage/crop/#crop_tile
- Montage Usage: https://legacy.imagemagick.org/Usage/montage/