#!/bin/sh
for f in *.jpeg; do
    echo $f
    g=`basename $f .jpeg`
    djpeg -pnm $f | pnmscale -xysize 160 120 > $g.pnm
    h=`pnmfile $g.pnm | awk '{print 120 - $6}'`
    if [ $h -gt 0 ]; then
	pnmpad -white -t`expr $h / 2` \
	              -b`expr $h - $h / 2` $g.pnm > $g.moo
	mv $g.moo $g.pnm
    fi
    ppmtotga $g.pnm > $g.tga 2> /dev/null
    rm $g.pnm
done

unset g
for f in *.tga; do
    if [ -n "$g" ]; then
	echo xmorph -start $g -finish $f
    fi
    g=$f
done

rm house.gif
for f in house?.0???; do
    tgatoppm $f | ppmquant 256 | ppmtogif > $f.gif
done

gifsicle --delay 50 -O2 *.gif > house.gif
