Pragmatism in the real world

Creating montages with ImageMagick

When creating my Year in Pictures post I decided that I wanted a montage of all the photos I had taken. In previous years, I’ve done this by taking a screenshot in an application where I try to set the zoom level correctly to get something acceptable.

This time, I decided to do it properly and guessed that ImageMagick could help. After googling, I came up with this process:

  • Export all images from Photos into a directory
  • Rename based on date so that they are in order:
    exiftool "-filename<DateTimeOriginal" -d "image-%Y%m%d-%H%M%S-%%f.%%e" *.jpeg
  • Create montage with ImageMagick:
    magick montage image*.jpeg -tile 21x -geometry 100x\> montage.jpg

The montage command takes the list of input images to use, then any options and then the name of the created image to create. The options I have used are:

  • -tile 21x: This sets the number of images per row. You can also set the number of rows by adding a number after the x, such as -tile 4x5. I picked 21 as I have 365 photos that are of 3:2 ratio and I wanted a roughly 16:9 ratio output image.
  • -geometry 100x\>: This resizes the width of the each image to 100 pixels with no padding. The x isn’t strictly needed, but reminds me that I’ve set the width (you set height with a preceding x, such as x100) and the < ensures that images smaller than specified width are not enlarged, again not strictly needed in this case. This is a very flexible option as you can see from the Image Geometry help section!

That’s it. I end up with the montage that I wanted! I also created a montage for this post with 20 pictures in a 5×4 grid using:

magick montage image*.jpeg -tile 5x -geometry 300x\> railway-montage.jpg

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *