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. It is also used in the batchVariants script that prepares the images for this website.

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

Rotating

mogrify -rotate "90" file.jpg

Rotates an image by 90 degrees clockwise.

Cropping

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

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.jpg output.jpg

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

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

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

Resizing

mogrify -geometry 50% file.jpg

Resizes the image down by half.

mogrify -geometry 1024x file.jpg

Resizes the image to a width of 1024px.

mogrify -geometry x800 file.jpg

Resizes the image to a height of 800px.

mogrify -geometry 800x800 file.jpg

Resizes the image to 800px at the longer side.

mogrify -density 72 -units pixelsperinch file.jpg

Changes the DPI of the image to 72.

Dithering

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

Dithers the image with 8 colors.

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

Dithers the image using a colortable.

Tiling

montage * output.jpg

Tiles all images in folder.

montage * output.jpg -background "#000000"

Sets the background color the black.

PDF conversion

convert file.pdf -flatten output.jpg

Converts a pdf to.jpg

Image Sequencing

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

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

Information

identify file.jpg

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) | meta | software