#!/bin/sh thumb_dir="${THUMB_DIR:-thumbs}" thumb_width="${THUMB_WIDTH:-240}" mkdir -p "$thumb_dir" main() { gallery=$( for image in "$@" do thumb="${thumb_dir}/thumb_$(basename $image)" test -f "$thumb" || gm convert "$image" -resize "$(( thumb_width * 2 ))" "$thumb" cat <
EOF done) cat < $gallery EOF } main "$@"