Scott Whitson

The Photo Export Script

Last updated: November 2026

I have a quick script to give photos a quick, automated treatment: lens correction, a border, and two fixed sizes.

It applies one style, web-frame, and writes 1600px and 400px JPEGs into processed/<slug>/{full,thumb}. The style is a single darktable borders module: white, about 0.7% of the long edge.

It depends on darktable-cli, Darktable being the software I use to edit photos more intentionally. Here's the script:

#!/usr/bin/env bash
# export-photos.sh: process raw files for the scottwhitson.com gallery
#
# Usage:
#   ./export-photos.sh <slug> <raw-file>...
#
# Applies the darktable style 'web-frame' (one 'borders' module, the white
# frame) and exports full and thumb JPEGs into <export dir>/<slug>/.
#
# Typical use, from a shoot already in the repository:
#   ./export-photos.sh 2026-01-17-travel \
#     ~/photos/repository/canon-r50/2026/20260117_17JAN26/*.JPG
#
# Requires: darktable-cli, with 'web-frame' imported. The style is in this repo
# at darktable-styles/web-frame.dtstyle; import it once in the GUI
# (lighttable → styles panel → import). A missing style stops the run.

set -euo pipefail

# The two paths the syncthing folder declares (dotfiles
# modules/syncthing-fleet.nix): the authoritative tree on the hub, and this
# host's synced copy of it. Keep in step with deploy.sh and bin/photo-ingest.
if [ -d /home/srv-data/photo/repository ]; then
  PHOTO_DIR=/home/srv-data/photo/processed
else
  PHOTO_DIR="$HOME/photos/processed"
fi

DT=darktable-cli
STYLE=web-frame
FULL_WIDTH=1600
THUMB_WIDTH=400
# darktable-cli has no --quality flag: JPEG quality is a core config value, and
# this machine's darktablerc says 95. Pass it explicitly so the number in this
# file is the one that gets used.
QUALITY=90

# --- Main -------------------------------------------------------------------
slug="${1:?usage: $0 <slug> <raw-file>...}"
shift
[ $# -eq 0 ] && { echo "!!! no raw files given" >&2; exit 1; }

echo ">>> slug: $slug   style: $STYLE   files: $#"

outdir="$PHOTO_DIR/$slug"
mkdir -p "$outdir/full" "$outdir/thumb"

for raw in "$@"; do
  [ -f "$raw" ] || { echo "!!! not a file: $raw" >&2; exit 1; }
  base="$(basename "$raw" | sed 's/\.[^.]*$//')"
  echo ">>> $base"

  # Full-size export
  $DT "$raw" "$outdir/full/${base}.jpg" \
    --style "$STYLE" \
    --width "$FULL_WIDTH" \
    --height "$FULL_WIDTH" \
    --hq 1 \
    --upscale 0 \
    --core \
    --conf "plugins/imageio/format/jpeg/quality=$QUALITY"

  # Thumbnail
  $DT "$raw" "$outdir/thumb/${base}.jpg" \
    --style "$STYLE" \
    --width "$THUMB_WIDTH" \
    --height "$THUMB_WIDTH" \
    --hq 1 \
    --upscale 0 \
    --core \
    --conf "plugins/imageio/format/jpeg/quality=$QUALITY"
done

echo ">>> done: $# file(s) → $outdir"