if [ $# -ne 1 ]; then
    echo "Exactly one argument is required (e.g., \"tiff2jpg.sh myfile.tiff\")"
    exit 1
fi
TIFF=$1

# Get the collection time and timestamp if present
MINUTES=`sesimage2collectiontime.rb $TIFF`
TIMESTAMP=`sesimage2datetime.rb $TIFF`
THISYEAR=`date +"%Y"`

# Derive jpg name from tiff name
BASE=${TIFF%.tiff}
JPEG=$BASE.jpg

# Perform the conversion by builing the command string then execute
echo "$TIFF -> $JPEG"
COPY="-draw 'text 1900,1850 \"Copyright MBARI $THISYEAR\"'"
DT="-draw 'text 1900,1900 \"$TIMESTAMP\"'"
COLL="-draw 'text 1900,1950 \"$MINUTES minute collection\"'"
cmd="convert $TIFF -pointsize 40 -fill red $COPY $DT $COLL $JPEG"
# Execute
eval $cmd
