#!/bin/bash

NBFRAMES=42
INTERVAL=17
DELAY=12

DEVICE=/dev/video1
GRABOPT="-o png -i sif -d $DEVICE"
GRABBED=/tmp/grabbed.png

sleep 3

for frame in $(seq 1 $NBFRAMES)
do
	figlet -W $(printf "%03d" $frame)
	fname=$(printf "/tmp/wcgrab%04d.png" $frame)
	echo $fname

	vgrabbj $GRABOPT > $GRABBED
	convert -resize 57% $GRABBED $GRABBED
 
	fname=$(printf "/tmp/wcgrab_a_%04d.png" $frame)
	convert -ordered-dither 8X8 $GRABBED $fname &

	fname=$(printf "/tmp/wcgrab_b_%04d.png" $frame)
	pngtopnm $GRABBED | ppmquant -nofs 15 > $fname

	fname=$(printf "/tmp/wcgrab_c_%04d.png" $frame)
#	pngtopnm $GRABBED | ppmquant -fs 15 > $fname
	/home/tth/Essais/PIL/atkinson.py $GRABBED $fname > /dev/null

	sleep $INTERVAL
	echo
done

echo all grabs done
sleep 15
echo creating GIF, please wait

convert -delay 10 /tmp/wcgrab*.png wcgrab.gif
wc -c wcgrab.gif

