How to Use ImageMagick to Generate a Contact Sheet

Of the three main ways to make a digital contact sheet, the ImageMagick method gives you the most control and works best at scale — large image batches, automated workflows, archive processing. Here’s the montage command that handles it, with every option explained and a label token reference so you can customize the captions to whatever you need.

How to Use ImageMagick to Generate a Contact Sheet
Text & Photos By David Coleman
Last Revised & Updated:

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

Have Camera Will Travel // Newsletter

Practical field notes, hands-on gear tests.

ImageMagick’s montage command builds contact sheets from a folder of images in one line — no Lightroom needed — with control over columns, labels, and sizes. The commands and a ready-made recipe are below.

Contact sheets go back to the film darkroom — a quick way to view a whole roll of negatives as positive prints on a single sheet. In the digital age, thumbnail grid views in apps like Lightroom and Capture One serve the same purpose, but there are still good reasons to want a standalone contact sheet file: photography school submissions, client proofs, or visual indexes for archived media.

There are several ways to make them digitally. The Lightroom method gives a good combination of ease and layout control. The Photoshop method is the quickest but the least flexible. The ImageMagick method covered here gives the most control — background color, label content, grid dimensions, font, spacing — but requires working in the terminal and some trial and error, since there’s no live preview.

Where ImageMagick really earns its place for contact sheets is at scale: large numbers of images, automated workflows, or batch processing an archive. If you only need a contact sheet occasionally, Lightroom or Photoshop are probably the more practical choice. If you’re doing this routinely or building it into an automated workflow, ImageMagick is worth the setup.

I’m assuming ImageMagick is already installed. If not, here’s the installation guide.

Creating a contact sheet with ImageMagick

The tool for this is ImageMagick’s montage command — in ImageMagick 7 (the current Homebrew default), called as magick montage.

Start by collecting all the images you want to include in a single folder and navigating Terminal to that folder. Using copies rather than originals is a sensible precaution.

Here’s a working example command that creates a contact sheet with filename labels, a white background, and an optional title header:

magick montage -verbose -label '%t' \
  -font /System/Library/Fonts/Helvetica.ttc -pointsize 11 \
  -background '#FFFFFF' -fill '#555555' \
  -define jpeg:size=300x300 \
  -geometry 300x300+5+5 \
  -auto-orient -tile 8x6 \
  *.jpg _contact-sheet.jpg

This produces a contact sheet with 8 columns and 6 rows (48 images per sheet). If you have more images than fit, ImageMagick creates additional sheets automatically, named _contact-sheet-0.jpg, _contact-sheet-1.jpg, and so on. The underscore prefix keeps the output file at the top of the folder when sorted alphabetically.

To add a title header to the sheet, pipe the output into a second magick command that adds a caption above it:

magick montage -verbose -label '%t' \
  -font /System/Library/Fonts/Helvetica.ttc -pointsize 11 \
  -background '#FFFFFF' -fill '#555555' \
  -define jpeg:size=300x300 \
  -geometry 300x300+5+5 \
  -auto-orient -tile 8x6 \
  *.jpg miff:- | magick - \
  \( -size 2480x -background white -fill black \
     -gravity center -font /System/Library/Fonts/Helvetica.ttc \
     -pointsize 36 caption:"Shoot Name" \) \
  +swap -append _contact-sheet.jpg

Replace "Shoot Name" with whatever title you want. The -size 2480x value is the sheet width, so the title centers correctly: columns × (cell width + 2 × gap), which is 8 × (300 + 10) = 2480 for this example. Change it if you change -tile or -geometry.

Command options explained

  • -verbose — prints processing details to the Terminal window as it runs. Doesn’t affect output; useful for troubleshooting.
  • -label '%t' — sets the caption below each thumbnail. %t is the filename without extension. See the label tokens section below for alternatives.
  • -font /System/Library/Fonts/Helvetica.ttc — font for labels. On a Mac, ImageMagick usually can’t find fonts by name (-font Helvetica gives an “unable to read font” error), so point it at the font file instead. Any .ttf, .otf, or .ttc path works; run magick -list font to see which fonts it does know by name.
  • -pointsize 11 — font size for labels. Adjust to taste.
  • -background '#FFFFFF' — background color as a hex code. #FFFFFF is white; #000000 is black.
  • -fill '#555555' — label text color. #555555 is a readable dark gray.
  • -define jpeg:size=300x300 — a pre-scale hint that tells ImageMagick to load input images at roughly this size rather than full resolution, which speeds up processing. Should match or exceed the -geometry value.
  • -geometry 300x300+5+5 — the size of each thumbnail cell (300×300px) plus the horizontal and vertical gap between cells (5px each). Adjust both values to change thumbnail size and spacing.
  • -auto-orient — rotates images automatically based on their EXIF orientation data. Useful for mixed-orientation batches.
  • -tile 8x6 — sets the grid as 8 columns × 6 rows per sheet. Change to any combination you need; use 8x0 to let ImageMagick calculate the row count automatically.
  • *.jpg — processes all JPEGs in the current folder. Change to *.png, *.tif, or *.{jpg,png} for other formats.

Label token reference

The -label option accepts tokens that pull information from each image. Useful combinations:

  • %t — filename without extension (default in the example above)
  • %f — full filename including extension
  • %d — directory component of the path
  • %m — file format (JPEG, PNG, etc.)
  • %w — image width in pixels
  • %h — image height in pixels
  • %b — file size in bytes
  • %i — image index (sequential number across the batch)

Tokens can be combined with plain text. For example:

  • -label '%f' — filename with extension
  • -label '%m %w x %h' — format and pixel dimensions
  • -label 'Image %i' — sequential numbering: “Image 1”, “Image 2”, etc.
  • -label '%d/%f' — directory path and filename

Automating with a drop folder

If you’re generating contact sheets regularly, you can attach this command to a macOS Folder Action so that dropping images into a designated folder automatically triggers the contact sheet build.

. Photo by David Coleman - havecamerawilltravel.com

Have Camera Will Travel // Newsletter

Practical field notes, hands-on gear tests, and the fun of exploring the world with a camera in hand.

The same Automator setup used in the metadata stripping guide and ImageMagick installation guide applies here — substitute the magick montage command as the shell script content, with the full Homebrew path (/opt/homebrew/bin/magick) in place of the bare magick call.

Found this helpful? Personalize your search results.
Add as Preferred Source