#!/bin/sh
#
# Remoark: THUMB will be created as GIF 87a, so it will become smaller,
# because no comments are included. THUMBs are made of 8 colors.
# In the FULL picture comments will be included, you may look at the comments
# using xv or ppicx. FULLs will be made of 4 colors to save some space.
#
# This routine is far from beeing perfect. Improvements you may think of:
# ppichange contrast, such that "non-white" pixel are never mapped to white,
# and "non-black" pixel are never mapped to black before ppicfix color
# reduction. This way you get an improved aliased picture.

x=640
y=640
z=0

name="`dirname \"$1\"`/`basename \"$1\" .g3`"

if [ ! -f "$name.g3" ]
then
	echo "Please give a G3 FAX file on the command line."
	echo "This will create a .thumb.gif and a .full.gif"
	echo ""
	echo "Missing file '$name.g3'"
	exit
fi

create()
{
echo "creating $name.$4 from $name.g3"
ppicg3 -sx-1 -f1 "$name.g3" |
ppicunpk |
ppiczoom -x$1 -y$2 -z$z |
ppicfix -c$3 |
ppic2gif -i$5 - $name.$4
}

create 100 100  8 thumb.gif t87a
create $x  $y   4 full.gif
