#!/bin/bash # This script creates little thumbnail images of jpeg images. # For my pages I decided to name the smaller images with _small # before the .jpg, so this script does that too. if test $# -lt 2 ; then echo "usage: $0 scale jpegfile [jpegfile...]" echo " (normally, I just type \"thumb 0.2 *\")" exit fi scale="$1" shift for rawname in $* ; do if test "${rawname%%.jpg}" = "$rawname" ; then # if not a JPEG continue; fi if test "${rawname%%_small.jpg}" != "$rawname" ; then # if already is a small continue; fi if test "${rawname%%_zoom.jpg}" != "$rawname" ; then # if is a zoom continue; fi echo "converting $rawname" djpeg -pnm "$rawname" | pnmscale $scale | cjpeg >"${rawname%%.jpg}_small.jpg" done