Concatenating images with ImageMagick


It sounds counter-intuitive, but I do almost all my image processing for this blog using my almost two-decade old Swiss Army Knife shell script library. Every image is scaled at multiple resolutions to save non-Retina readers bandwidth, and is sent through the excellent pngcrush and jpegoptim tools to losslessly reduce their size.

On the weekend I learned that ImageMagick’s append option can also be used to place images side by side, either horizontally or vertically. Note the operator changes from a minus to a plus:

$ magick convert \*.png -append vertical.png
$ magick convert \*.png +append horizontal.png

My mnemonic is to imagine the - is a dividing line, with images above and below.

Some of you may now be reasonably asking why I haven’t given a photographic example. That’s a great question. GraphicsMagick also has a similarly-named option, though I haven’t tested.

Author bio and support


Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!