Created
August 16, 2026 02:37
-
-
Save Daij-Djan/3cb3a367bdb9ea47e608a17412db61f0 to your computer and use it in GitHub Desktop.
make a photosheet for photos in folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Usage: make_contact_sheets.sh <source_dir> <dest_dir> | |
| # Builds numbered contact-sheet grids (chronological, labeled by filename) for one event. | |
| set -e | |
| SRC="$1" | |
| DEST="$2" | |
| CHUNK=24 # photos per sheet | |
| TILE="6x4" | |
| THUMB="240x240" | |
| mkdir -p "$DEST" | |
| # Gather image files (jpg/jpeg/png/heic), skip videos, skip meta "-=...=-" overview files, sort chronologically (filenames are timestamps) | |
| FILES=() | |
| while IFS= read -r line; do | |
| FILES+=("$line") | |
| done < <(find "$SRC" -maxdepth 3 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.heic" \) ! -iname "-=*" | sort) | |
| TOTAL=${#FILES[@]} | |
| echo "Found $TOTAL photos in: $SRC" | |
| i=0 | |
| sheet=1 | |
| while [ $i -lt $TOTAL ]; do | |
| batch=("${FILES[@]:$i:$CHUNK}") | |
| outfile=$(printf "%s/contact_sheet_%02d.jpg" "$DEST" "$sheet") | |
| magick montage \ | |
| -font "/System/Library/Fonts/Supplemental/Andale Mono.ttf" -pointsize 13 -fill white -background '#202020' \ | |
| -auto-orient -label '%f' \ | |
| "${batch[@]}" \ | |
| -geometry "${THUMB}+6+6" -tile "$TILE" \ | |
| "$outfile" | |
| echo "Wrote $outfile (${#batch[@]} photos)" | |
| i=$((i + CHUNK)) | |
| sheet=$((sheet + 1)) | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment