#!/bin/ksh
# convert jpg file to rgb file
# resize it to first two command-line paramters (xsize and ysize)
# convert resized rgb file to gif
#
# usage: $0 xsize-pixels ysize-pixels filepath [filepath [...]]
#
PATH=/usr/sbin:$PATH
#
xsize=$1
ysize=$2
shift;shift
#
TEMPFILE=temp$$.rgb
trap "rm $TEMPFILE" 1 2 3 9 15
#
for i in $*
do
        filename=`basename $i .[jJ][pP][gG]`
        filedir=`dirname $i`
        echo $i $TEMPFILE $filedir/$filename.rgb
        imgcopy $i $TEMPFILE
        fitimg $TEMPFILE $filedir/$filename.rgb $xsize $ysize
	imgcopy $filedir/$filename.rgb $filedir/$filename.gif
done
rm $TEMPFILE
