screenshots.sh is a small Bash utility for preparing and combining screenshot
images with ImageMagick. It can create one montage, pair corresponding images
from several sets, process every image independently, or split one long
screenshot into page-sized PDF or PNG output.
- Bash 3.2 or newer
- ImageMagick with
magickonPATH - The separate ImageMagick
montagecommand for montage and zip modes - Perl with
Time::HiResandCLOCK_MONOTONICfor interactive or verbose stage timing - A discoverable system font for montage and zip modes, and for pagination when a header or footer is enabled
On macOS with Homebrew:
brew install imagemagickClone the repository and put the script somewhere on your PATH:
git clone https://github.com/stansult/screenshots.git
cd screenshots
ln -s "$PWD/screenshots.sh" /usr/local/bin/screenshots.shYou can also run it directly from the cloned directory with
./screenshots.sh.
Keep presets.conf and progress.sh beside screenshots.sh; the script reads
them at startup. See Presets to add or edit preset definitions.
screenshots.sh -i PATTERN -o FILE [options] # montage
screenshots.sh -i PATTERN -i PATTERN [-o DIR] [options] # zip
screenshots.sh -i PATTERN --each [-o DIR] [options] # each
screenshots.sh -i IMAGE --paginate [-o FILE.pdf] [options] # paginated PDF
screenshots.sh -i IMAGE --paginate --output-pages [-o DIR] # PNG pages
Always quote input patterns so the script, rather than the calling shell, expands them.
Use the short general help for discovery, or open a complete mode reference:
screenshots.sh --help
screenshots.sh --help montage
screenshots.sh --help zip
screenshots.sh --help each
screenshots.sh --help paginate
screenshots.sh --help presets-h is an exact alias for --help, including topic forms such as
screenshots.sh -h paginate.
Use Montage to combine multiple images into a single grid. For example, arrange mobile-app screenshots in flow order, then add arrows or notes to illustrate the user journey.
One input pattern produces a single grid image. Matches are pathname-sorted.
The default output is output.png; when the output itself matches the input
pattern, it is excluded from the inputs.
screenshots.sh -i "usage*.png" -o usage-grid.png
screenshots.sh -i "usage*.png" -c 50 --width 750 --shadow
screenshots.sh -i "*.png" --tile 5x0 --gap 20x20Use Zip to compare corresponding screens from different image sets. For example, compare the same mobile-app flow on iOS and Android screen-by-screen to make platform-specific differences easy to spot.
Two or more input patterns enable zip mode. Each pattern is independently sorted bytewise, then files at matching positions are placed together in a montage. Every pattern must match the same number of files, and pattern order determines the left-to-right order within each montage.
screenshots.sh \
-i "android/*.png" \
-i "ios/*.png" \
-o comparisonsResults are written as 1.png, 2.png, and so on in a new timestamped
zip-* directory. Its default tile layout is Nx1 for N patterns. An explicit
tile layout overrides that default, but its column count is capped at N.
Use Each to apply the same transformations to a batch while keeping each image separate. For example, resize a folder of similar screenshots to a consistent width, and cut-off the unneeded header from each.
screenshots.sh -i "usage/*.png" --each -c 50 --width 750Results retain their original filenames and are written to a new timestamped
each-* directory.
Use Paginate to split one long screenshot into fixed-ratio pages for printing or sharing. For example, capture a long web page with GoFullPage or a similar full-page capture tool, then paginate the resulting image.
It accepts exactly one single-frame raster image and slices it from top to bottom into portrait Letter, A4, or Legal pages. Output is raster-only and no OCR or text layer is added.
Without an explicit output, the PDF is written beside the source using the source basename:
screenshots.sh -i long-article.png --paginate
# creates long-article.pdfChoose a paper size, add uniform white pixel margins, or repeat source rows between pages:
screenshots.sh -i long-article.png --paginate --paper a4 \
--margin 40 --overlap 20 -o article.pdfOptional print-style headers and footers reserve space inside the fixed-ratio
page. The header shows the image creation date and time on the left, with
optional title text on the right. The footer shows page/total-pages on the
right:
screenshots.sh -i long-article.png --paginate --header --footer \
--header-line --footer-line --title "Article title" -o article.pdfCreation time is selected from embedded capture metadata, a recognized
GoFullPage filename timestamp, filesystem creation time, then filesystem
modification time. The header uses a compact format such as
Sep 10, 2026 · 11:52 PM. Long titles are shortened with an ellipsis.
To use a source capture time on a combined image, set its EXIF
DateTimeOriginal before paginating; the header prioritizes this tag. For
example: exiftool -DateTimeOriginal='YYYY:MM:DD HH:MM:SS' combined.png.
ExifTool saves the original as a _original backup by default.
Use --output-pages to create lossless PNG pages instead of a PDF. A fresh
pages-<timestamp> directory is created in the current directory:
screenshots.sh -i long-article.png --paginate \
--output-pagesUse -o to select a parent directory. It is created when missing:
screenshots.sh -i long-article.png --paginate \
--output-pages -o exportsPages are named page-001.png, page-002.png, and so on. Every page has the
selected paper ratio and identical pixel dimensions; unused space on the final
page is white. Page breaks are fixed geometrically and do not inspect content.
Existing crop and resize options work in paginate mode. Auto-orientation,
cropping, and resizing happen before margins and page slicing. Montage and
appearance options cannot be combined with --paginate.
Presets are named bundles of existing options. They can select a mode, while explicit options override preset values regardless of their position in the command. Only one preset may be used per command.
screenshots.sh -i document.png --preset paginated-documentSee PRESETS.md for the available presets, their exact option
bundles, title fields, and override examples. For a concise command-line
summary, use screenshots.sh --help presets or screenshots.sh -h presets.
The mode-specific help pages are the authoritative command-line reference. This section summarizes every public option and the important compatibility rules.
| Option group | Montage | Zip | Each | Paginate |
|---|---|---|---|---|
| Crop and resize | Yes | Yes | Yes | Yes |
| Tile, gap, gravity, background | Yes | Yes | Rejected | Rejected |
| Trim, border, shadow | Yes | Yes | Yes | Rejected |
--font |
Yes* | Yes* | Rejected | Header/footer |
| Pagination options | Rejected | Rejected | Rejected | Yes |
-O, --overwrite |
Yes | Rejected | Rejected | PDF only |
* Montage and zip do not draw visible text, but ImageMagick's montage
command still initializes text rendering and can fail without a usable font.
The script discovers one automatically; --font FILE overrides that choice.
Supplying two or more -i patterns selects zip mode. --each requires exactly
one input pattern. --paginate requires exactly one input occurrence resolving
to one readable, regular, non-symlink, single-frame raster image.
-i,--input PATTERNselects files with a quoted glob. Repeat it to use zip mode.-o,--output FILE|DIRhas mode-specific meaning: montage output file; zip/each parent directory; pagination PDF filename; or PNG parent directory with--output-pages. It must be a literal path and cannot be repeated.-e,--eachprocesses matched files separately instead of creating a montage.-p,--paginateslices exactly one long image into pages.--preset NAMEapplies one named option bundle. The preset may select a mode; explicit options override its values in either argument order. See PRESETS.md for the catalog.--output-pageswrites PNG pages to a freshpages-<timestamp>directory instead of a PDF. With this option,-o DIRselects its parent directory, which is created recursively when missing.
-w,--width Nshrinks images to a maximum pixel width; omitted by default. It preserves aspect ratio and never enlarges.-H,--height Nsimilarly sets an optional maximum pixel height. Width and height may be combined as a bounding box.-c,--crop [N]cropsNpixels from every side before resizing.-ct/--crop-top,-cb/--crop-bottom,-cl/--crop-left, and-cr/--crop-rightoptionally add side-specific crop amounts. A bare crop flag or zero has no effect. Repeating the same crop flag causes that flag to be ignored with a notice.
--paper SIZEselectsletter(default),a4,legal, or a custom portraitWIDTHxHEIGHTaspect ratio such as2038x2807. Custom dimensions define proportions, not literal output pixels. Equivalent ratios produce the same page geometry. Custom PDFs use a 612-point width and derive their height from the requested ratio.--margin NaddsNwhite output pixels on every side (default:0).-mt/--margin-top N,-mr/--margin-right N,-mb/--margin-bottom N, and-ml/--margin-left Nadd pixels to the corresponding side in addition to--margin(default:0each).--overlap NrepeatsNpreprocessed source rows between pages (default:0); it must be smaller than the calculated slice height.--headeradds a 6-point creation date/time header.--footeradds 6-pointpage/total-pagesnumbering.--header-lineadds a 0.25-point#d0d0d0rule below an enabled header.--footer-lineadds the same rule above an enabled footer.--title TEXTadds header-right text and requires--header.{filename}expands to the complete input filename and{stem}to its name without the final extension. Use{{or}}for a literal brace; unknown or unmatched fields are rejected.--page-font-size Noverrides the 6-point header/footer font size with a positive value below 24 points and requires--headeror--footer.--font FILEselects the visible header/footer font and requires--headeror--footer; a system font is discovered automatically when omitted.
Headers and footers use 24-point bands and a 12-point horizontal text inset. These reserved bands and all four outer margins remain inside the selected paper ratio. Increasing left/right margins widens the fixed-ratio canvas and can reduce the page count; increasing top/bottom margins consumes vertical capacity and can increase it.
All options in this subsection require --paginate. -O is invalid with
--output-pages; PNG page directories are never overwritten or merged.
-t,--tile COLSxROWSsets the montage grid. A zero lets ImageMagick determine that dimension automatically. The montage default is10x0; zip defaults toNx1, where N is the number of input patterns.-g,--gap XxYsets horizontal and vertical pixel gaps (default:15x15).-G,--gravity VALUEsets tile alignment (default:north). Accepted values arenorth,south,east,west,center,northeast,northwest,southeast, andsouthwest.--background COLORsets the montage background (default:transparent). ImageMagick color names and values such aswhiteand#ff0000are valid.
--trimenables final trimming; this is the montage and zip default.--no-trimdisables final trimming; this is the each-mode default.--trim-fuzz Nsets trim tolerance as a percentage (default:0) and is rejected when trimming is disabled.-b,--border [N]adds a border. A bare flag uses width1, and an explicit width must be positive; in montage and zip modes it is applied to individual tiles.--border-color COLORsets border color (default:black) and requires--border.-s,--shadowadds a drop shadow; disabled by default. It is applied to the finalized montage in montage/zip mode and to each output in each mode.--shadow-color COLORsets shadow color (default:gray) and requires--shadow.--font FILEselects the font used internally by ImageMagick in montage and zip modes, or the visible decoration font in pagination. A system font is discovered automatically when omitted. Each mode rejects it because it does not render text.
-O,--overwriteoverwrites an existing montage or paginated PDF without prompting. It is rejected in zip/each mode, which always create fresh output directories, and with--output-pages.- Primary operational messages use local
[HH:MM:SS]timestamps in normal and verbose runs. A[YYYY-MM-DD]line precedes the first message and is repeated at the end only when the run crosses midnight. Continuation lines and help output remain undecorated. Every run reportsprocessing:before work begins. Interactive stderr shows live stage progress with elapsed seconds after 5 seconds; completed stages show a finish timestamp and a(took N.Ns)duration only when they take at least 10 seconds. Verbose mode prints timestamped stage starts and completions instead of a spinner, even when stderr is redirected. Stage durations use PerlTime::HiResmonotonic time, so wall-clock adjustments do not affect them. -v,--verboseprints additional timestamped processing details to standard error.-h,--helpshows concise general help. Either spelling acceptsmontage,zip,each,paginate, orpresetsfor detailed help.
- Montage writes
output.pngby default and creates a missing output parent. If its destination exists, an interactive terminal offers overwrite or keep-both;-Oskips that prompt. - Zip and each output go into fresh timestamped directories. Their selected parent and any missing ancestors are created automatically; a same-second name collision receives a numeric suffix.
- Paginated PDF defaults beside the input and requires an existing writable
parent. An existing PDF prompts in an interactive terminal, fails safely in
non-interactive use, or is replaced atomically with
-O. - Paginated PNG output uses a fresh timestamped directory. Its parent is created automatically, but must be a real writable directory rather than a symbolic link. A collision receives a numeric suffix.
Crop and shrink-only resize run per input in every mode; pagination performs auto-orientation first. Montage and zip then apply per-tile borders while combining, followed by final trimming and shadows. Each mode applies trim, border, and shadow to every independent output. Pagination instead slices the preprocessed image and reserves margins and optional header/footer bands inside the final fixed-ratio page rather than adding them outside it.
Some ImageMagick installations have no registered default font. Even a montage without visible labels can then fail while ImageMagick initializes text rendering. The script works around this by discovering a readable system font and passing it to ImageMagick explicitly.
To select a particular font instead:
screenshots.sh -i "usage/*.png" --font /path/to/font.ttfIf automatic discovery fails, the script exits with instructions to install a
system font or use --font.
Some ImageMagick installations disable PDF writing through their security policy. Paginate mode reports this condition without leaving a partial PDF. PNG pagination remains available without PDF support:
screenshots.sh -i long-article.png --paginate \
--output-pages