#!/bin/bash

if [ ! -d "$1" ]; then
    echo "Usage:"
    echo "  $0 image-directory"
    exit 1
fi

if [ ! -r "$1/options" ]; then
    echo "options file not found!"
    exit 1
fi

# read options
. $1/options

if [ -z "$GAMMA" ]; then
	GAMMA=1.6
fi
if [ -z "$DELAY" ]; then
	DELAY=30
fi

OUTPUT=`basename $1 |awk -F- '{print $1}'`.$OUTPUT
THUMBOUT=`basename $1 |awk -F- '{print $1}'`t.jpg
echo "Creating image $OUTPUT"

# create thumbnail
if [ -r "$1/$THUMBNAIL" ]; then
    kdc2jpeg -g $GAMMA +P -C Chris.Studholme@canada.com -p -w 128 -h 128 -q 70 $1/$THUMBNAIL $THUMBOUT
    echo
fi

# create movie
. `dirname $0`/make-movie-$MODE
