There is a very good and comprehensive list of ‘basic‘ commands, but I find it dwarfs the selection that I actually need, so here are some useful Imagemagick commands that I can never remember how to use.
Mogrify vs Convert
It’s worth pointing out that Imagemagick has two main commands for modifying images. The main difference is that ‘convert‘ tends to be for working on individual images, whereas ‘mogrify‘ is for batch processing multiple files.
Another key distinction is that convert is designed to modify an image and output to a separate file. Mogrify on the other hand will quite happily change the original file, unless you specify a separate output location. Be careful not to modify images without a backup!
Processing Individual Images
The convert command is used to operate on single images and it’s repertoire of functions is much greater than that of mogrify.
Add file name as label to image
convert input.jpg -gravity South -annotate 0 '%f' output.jpg
For a more advanced labelling method, see here.
Batch Process Images
Batch processing with mogrify is probably where Imagemagick comes into its own. In these examples, the script will operate on all png files within the current folder.
Change format to jpg:
mogrify -format jpg *.png
Save as a jpg and output to the directory ‘new_folder’:
mogrify -format jpg -path ./new_folder *.png
Save as a jpg, output to ‘new_folder’, resize to 50%:
mogrify -format jpg -resize 50% -path ./new_folder *.png
For more complex processes, it is recommended that you write your own script that uses ‘convert’ rather than ‘mogrify’.
Check out this list of libraries, modules and packages for interfacing with your favourite scripting language.