Ian Obermiller

Part time hacker, full time dad.

Combining pictures into a single photo sheet


Ever wanted to print four photos on a single 4×6 (this is all wallet photos are, after all)? While this sounds like it should be simple, most photo services, like Costco, don't let you print 2×3 photos unless you order 4 at once, and even then they charge several times the price of a single 4×6. After searching around for solutions, I figured out how to spend a few minutes at the command line using ImageMagick instead.

Step 0: Install ImageMagick

Download and install ImageMagick. On MacOS, it is easiest to use homebrew:

brew install imagemagick

Step 1: Make photos the same size

First, you need to make sure all your photos are the same size, and thus aspect ratio. I'll assume you want to combine four 2×3 photos into a single 4×6. To resize to a particular aspect ratio:

convert input.jpg -gravity north -crop 2:3 +repage output.jpg

You may want to swap out north for south or center, depending on the image. See the docs on crop and gravity. Note the filenames input.jpg and output.jpg, you should avoid editing your source files.

Now your photos will be the same aspect ratio, but if they are not the same size, you should resize them to the smallest size:

# find the size using "identify"
identify a.jpg

# resize
convert input.jpg -resize 2000x3000 output.jpg

Step 2: Combine and tile

Next, we'll use the montage command to tile the photos into a single image. Since we are combining into two rows and two columns, the 2×3 aspect ratio will be preserved.

montage a.jpg b.jpg c.jpg d.jpg -geometry +0+0 -tile 2x2 combined.jpg

Note the "-geometry +0+0", which indicates there should be no horizontal or vertical spacing between them, and that they should be full size. "-tile 2×2" indicates two rows and two columns.

And there you have it! If you have to do this more frequently, I'd recommend a tool with a nice UI, like Photosheet.