#! /bin/bash # Makes thumbnails for gallery.php set -eu thumbdir=thumb if test -d "$thumbdir" then for file in "$thumbdir"/* do test -f $(basename "$file") || rm "$file" done else mkdir "$thumbdir" fi for x in * do test -f "$x" || continue test -f "$thumbdir/$x" -a "$x" -nt "$thumbdir/$x" && continue file --brief --dereference --mime "$x" 2>/dev/null | grep -q '^image\/' || continue echo -n "$x: " convert -size 300x200 "$x" -resize 300x200 "$thumbdir/$x" echo done. done