How to Use ImageMagick to Generate a Contact Sheet

Contact sheets might be old-fashioned, but they’re still very useful even with digital photography.

And one of the many things that ImageMagick can do with photos is to assemble them into a contact sheet. Here’s how to do it.

Text & Photos By David Coleman
Last Revised & Updated:
Filed Under: Workflow

I MAY get commissions for purchases made through links in this post.

Contact sheets are an old idea going back to film days. They are a quick way of looking over strips of film, and they’re especially useful for negatives, where you can parse a positive print much more effectively than looking directly at negative film.

They get their name from the way they’re made. Rather than putting the film in the enlarger head and projecting it and magnifying it onto the paper below, the film is laid directly onto the paper. So you don’t get any magnification, but you do get wonderfully sharp versions of the same size as the original film. And you can fit a whole 36-exposure roll of 35mm on a single 8×10 sheet of print paper.

These days, with digital photography, views like the multi-image thumbnail grids baked into apps like Lightroom or Capture One are the modern equivalent. But sometimes it’s still useful to have a single file showing thumbnails. Photography schools still use them quite often, for example.

There are a number of ways to make them. I’ve previously covered how to make contact sheets in Lightroom. That method gives a good combination of ease-of-use with control over the output. A quicker and simpler method, but also one that gives you the least control over the output, is to use a plugin that comes pre-installed with Photoshop.

Of these methods, the ImageMagick method for creating contact sheets gives you the most control. But that does come at a price of some complexity. It involves using command-line code and inevitably some trial and error, because you won’t get real-time previews during the process.

But The upside is that ImageMagick works especially well with large numbers and images and excels in automated workflows when combined with things like Mac’s Automator actions or Folder Actions or task launchers like Alfred.

If you’re only doing this rarely, the Lightroom or Bridge methods probably make more sense. But its if you find yourself doing this routinely or creating a large number of contact sheets to cover a photo archive that the ImageMagick method really shines.

So here’s a quick guide to using ImageMagick on Mac to create contact sheets. I’m assuming here that you’ve already installed it; if not, I have a guide on how to install ImageMagick on Mac separately (and it’s easier than it looks).

Creating a Contact Sheet with ImageMagick

The ImageMagick command we’re going to use here is the montage tool.

There’s a lot here you can customize to your own needs and preferences. I’m going to start with a basic example and then provide ways you can customize it to your needs.

  1. Save your images in a single folder. It’s going to make things much easier if all the images you want to include are combined in a single folder. For safety, I recommend using copies rather than originals. Then navigate to that folder.
  2. Runn the ImageMagick Command: The ImageMagick command will need to handle resizing images to thumbnail size, arranging them in a grid, adding a filename below each thumbnail, and setting the overall canvas size to 8×10 inches with a white background.

Here’s an example command:

montage -verbose -label '%t' -font Helvetica -pointsize 11 -background '#FFFFFF' -fill '#555555' -define jpeg:size=250x250 -geometry 300x300+5+5 -auto-orient *.jpg -resize 3000x2400^ -gravity center -extent 3000x2400 -tile 8x - | convert - -background white -fill black -gravity center -font 'Helvetica-Bold' -pointsize 36 -size 3000x caption:"Shoot Name" - -append _contact-sheet.jpg

Here’s an explanation of what’s going on here:

The given terminal command uses ImageMagick’s montage to create the grid. The Convert part is just there to add the sheet title and can be omitted.

Let’s break down each command and option, along with alternative values:

montage Command:

  • montage: The ImageMagick command for arranging and composing multiple images into a single image (contact sheet).
Options to Customize the Command
  • -verbose: Displays verbose output during processing, providing detailed information about the operation. This doesn’t affect the output; it’s just showing you what it’s doing in the Terminal window.
  • -label '%t': Sets the label for each image. The one I’ve used in this example (%t) represents the image filename without the extension. But you can customize this in many ways. Here are some alternative tokens you can mix and match.
    • %f: The full filename, including the extension.
    • %d: The directory component of the filename.
    • %p: The path component of the filename (directory and file).
    • %m: The image file format (e.g., JPEG, PNG).
    • %w: The image width in pixels.
    • %h: The image height in pixels.
    • %s: The image size in pixels (e.g., “800×600”).
    • %b: The image file size in bytes.
    • %q: The image quality (applies to some formats like JPEG).
    • %i: The image file index (when processing multiple images).

      And some practical examples:
    • -label '%f': Displays the full filename with the extension.
    • -label '%m %w x %h': Displays the image format followed by its dimensions.
    • -label '%d/%f': Displays the directory followed by the filename.
    • -label 'Image %i': Adds a label like “Image 1,” “Image 2,” etc., for each image in a sequence.
  • -font Helvetica: Specifies the font to use for labels. You can replace “Helvetica” with any other available font name. Helvetica and Arial are safe, clean choices that are easy to read, but you can use whatever you like.
  • -pointsize 11: Sets the font size for labels. You can adjust this to change the label size.
  • -background '#FFFFFF': Sets the background color for the contact sheet to white (#FFFFFF). You can specify different background colors using hexadecimal color codes or color names.
  • -fill '#555555': Sets the text fill color for labels to a dark gray (#555555). You can use alternative colors.
  • -define jpeg:size=250x250: Defines the maximum size for input images. Images larger than this size will be scaled down to fit within the specified dimensions (250×250). You can change the size as needed.
  • -geometry 250x250+5+5: Sets the size and position of each image in the contact sheet. In this case, images are resized to 250×250 pixels and placed with a 5-pixel margin from the top-left corner. You can adjust the size and margin.
  • -auto-orient: Automatically orients images based on their EXIF data to ensure they are displayed correctly. Useful for handling images with varying orientations.
  • *.jpg: Specifies the input image files. Replace *.jpg with the appropriate file pattern if you have images with different extensions.

Finally, the command specifies the input from the montage command using -, and the output is saved as “_contact-sheet.jpg.” You can change the output filename to your preference; I’ve added the underscore to the beginning simply so that it shows up at the top of the folder.

To run this command, you can copy and paste from above (or your customized version) directly into a Terminal prompt. Unlike some code editors, Terminal accepts copied and pasted text, so you don’t need to retype everything manually (thankfully!).

Amp Up the Workflow By Creating an Automatic Drop Folder

If you regularly need to create contact sheets or need to create a lot of them, you can set this up as an automatic drop folder using Mac’s built-in Automator tool and Folder Actions. You can do similar things on Windows, but since I haven’t used Windows in years, I’m not sure of the specific tools or methods for doing that on that operating system.

What this means is that anytime you drop a batch of images into the specified folder, it will automatically create a contact sheet from those images.

Setting this up involves several more steps but builds on the basic command above. I’ll aim to put together a separate guide on it. Or you can look at the several other examples I have here of attaching ImageMagick commands to Folder Actions to use as a starting point.

You could also integrate these with launchers like Alfred, but that’s a bit beyond the scope of this post.

Useful ImageMagick Tasks for Photographers

I’ve put together some separate guides with ImageMagick recipes for particular tasks that I’ve found useful in a photography workflow.

Stay tuned: I’ll add them here as I create new ones.

Profile photo of David Coleman | Have Camera Will Travel | Washington DC-based Professional Photographer

Text & Photos by David Coleman

I'm a professional photographer based in Washington DC. Seven continents, up mountains, underwater, and a bunch of places in between. I've been shooting for 30+ years, and my my photos and time-lapse videos have appeared in a bunch of different publications from major newspapers to magazines and books, billboards, TV shows, professional sports stadiums, museums, and even massive architectural scrims covering world-famous buildings while they're being renovated. You can see some of my travel photography here and here.

Leave a Comment