Creating images quickly using montage from imagemagick

I was looking for a way to combine images together programmatically, and spent some time dabbling around in gimpfu python land without getting very far at all.

Who would have thought just placing one image next to another could get so hairy?

This image was created using a single command line

What if I said that it was possible to create the above image from three images using a single command line? Read on!

I had one of those “Aha!” moments of discovery when I chanced upon this article: Imagemagick montage usage.

montage -geometry 200X200+2+1 foo.png bar.png foobar.png

No script involved, just a single command line; and that resizes both foo.png and bar.png to 200 by 200 pixels, adds some default spacing between them (two pixels horizontal, one pixel vertical), and saves the output to foobar.png.

If you want the background to be transparent, and to add a drop shadow, like I did, it is as simple as:

montage -shadow -background None -geometry 200X200+2+1 foo.png bar.png foobar.png

You can even force the images to “tile” in a single horizontal row, like so:

montage -shadow -background None -tile x1 -geometry 200x150+5+5 foo.png bar.png foobar.png

… or a single vertical row, like so:

montage -shadow -background None -tile 1x -geometry 200x150+5+5 foo.png bar.png foobar.png

That is all that I needed for what I was doing, but this article explores quite a few other nifty things that the montage tool does - check out the polaroid filter:

Imagemagick montage with polaroid filter

Copyright © 2008-present Brendan Graetz