Combining images using ImageMagick

Recently, I had to combine two images of an ID card into a single image with both of them stacked vertically. You can do this using any image editing program like Adobe Photoshop. This can be accomplished significantly faster with a single command using ImageMagick.

You can install ImageMagick using Homebrew, if you are on a Mac.

brew install imagemagick

After installing ImageMagick, you can combine all the images in a particular folder into a single image with the following command. Although this command uses a glob pattern to target multiple files, you can specify file names as well. ImageMagick is a very flexible tool and can be used to perform a variety of image manipulation operations. It also supports popular image formats.

convert -append *.jpg combined.jpg

To stack images horizontally, you can use the following command

convert +append *.jpg combined.jpg

Happy image editing!

Subscribe to the newsletter

Get emails from me about software development, technology and more!