#!/bin/sh
# handle gif file for latex, expects args %f %S
set -e			# die on any error
BASE=`basename $1 .gif`
IN=$2			# input file
OUT=$BASE.eps		# output file
TMP=$BASE.ps		# temporary file

[ -f "$IN" ] || exit 1	# ensure our file exists
# make sure our temp file does not already exist
if [ -f "$TMP" ]; then
   echo "$0: $TMP is in the way" 1>&2
   exit 1
fi

giftopnm "$IN" | pnmtops -noturn > "$TMP"
ps2epsi "$TMP" "$OUT" 1>&2
rm -r "$TMP"
echo "\\includegraphics{$OUT}"
