Commmonly used imagemagick commands

ImageMagick is an open source tool for editing and converting raster images created in 1987 by John Cristy.

I use ImageMagick on the command line for quick image edits such as cropping, resizing or rotating.

Use convert to create a new output file or mogrify to overwrite the input file.

Rotating

mogrify -rotate "90" file.png

Rotates an image by 90 degrees clockwise.

Cropping

convert -crop 640x480+50+100 +repage input.png output.png

Crops the image at X:50 Y:100 to a size of W: 640 H:480.
+repage will prevent export of the cropped area.

convert -crop 3:2+50+100 +repage input.png output.png

Crops the image at X:50 Y:100 to a ratio of W: 3 H:2

convert -crop 3:2+50+100 +repage input.png output.png

Crops the image at X:50 Y:100 to a ratio of W: 3 H:2

Resizing

mogrify -geometry 50% file.png

Resizes the image down by half.

mogrify -geometry 1024x file.png

Resizes the image to a width of 1024px.

mogrify -geometry x800 file.png

Resizes the image to a height of 800px.

mogrify -geometry 800x800 file.png

Resizes the image to 800px at the longer side.

mogrify -density 72 -units pixelsperinch file.png

Changes the DPI of the image to 72.

Dithering

convert input.png -dither FloydSteinberg -colors 8 output.png

Dithers the image with 8 colors.

convert input.png -dither FloydSteinberg -remap colortable.gif output.png

Dithers the image using a colortable.

Tiling

montage * output.png

Tiles all images in folder.

montage * output.png -background "#000000"

Sets the background color the black.

PDF conversion

convert file.pdf -flatten output.png

Converts a pdf to.png

Image Sequencing

convert -delay 200 -loop 0 *.png output.gif

Creates an infinitely looping GIF with 2 seconds delay between each frame.

Information

identify file.png

Displays information on the file such as width and height.

Offline Documentation

To make the documentation available offline, install the imagemagick-6-doc package.

Links

incoming(2) | software | meta