#!/bin/csh # Shell Script: thumbnail # Filename: thumbnail # Programmer: Ben Y. Yoshino # Description: Creates thumbnails of specified images # Dependencies: This script requires the NetPBM package in your path # Copyright info: Permission to use, copy, modify and distribute this # software and its documentation for any purpose and # without fee is hereby granted, provided that the # above copyright notice and this permission notice # appear in supporting documentation. This software is # provided "as is" without expressed or implied # warranty. Ben Y. Yoshino will not be held liable for # any damages whatsoever resulting from the use of this # software. # # Copyright 1995, Ben Y. Yoshino. # All rights reserved. # # Check the arguments if ($#argv == 0) then echo "Error: $0:t [-w width] [-h height] [-s suffix] file(s)..." exit 1 endif set width height=32 suffix=small set files=() while($#argv) switch ($1) case -w: if ($#argv > 1) then set width="$2"; shift endif breaksw case -h: if ($#argv > 1) then set height="$2"; shift endif breaksw case -s: if ($#argv > 1) then set suffix="$2"; shift endif breaksw case -help: case -x: case -?: echo "Usage: $0:t [-w width] [-h height] [-s suffix] file(s)..." exit 1 default: set files=($files $argv[1]) breaksw endsw shift end @ width = $width + 0 @ height = $height + 0 if ($width == 0) unset width if ($height == 0) unset height foreach arg ($files) if ("$arg" =~ -*) continue if ($arg:e =~ [jJ][pP][gG] || $arg:e =~ [jJ][pP][eE][gG]) then set decode=djpeg set quant=cat set encode=cjpeg else set decode=giftopnm set quant="ppmquant -fs 256" set encode=ppmtogif endif if ($?width && $?height) then $decode $arg | pnmscale -width $width -height $height | ppmnorm | \ $quant | $encode > ${arg:r}.$suffix.${arg:e} else if ($?width) then $decode $arg | pnmscale -width $width | ppmnorm | \ $quant | $encode > ${arg:r}.$suffix.${arg:e} else if ($?height) then $decode $arg | pnmscale -height $height | ppmnorm | \ $quant | $encode > ${arg:r}.$suffix.${arg:e} endif end