#!/bin/sh

command="convert -dispose previous"

f=prefix.png
x=8
while [ $x -gt 0 ]; do
    command="$command \\( -delay 100 $f -scale 205x205 -crop 200x200+0+5 +repage -background white -alpha remove \\)"
    command="$command \\( -delay 100 $f -scale 205x205 -crop 200x200+0+0 +repage -background white -alpha remove \\)"
    x=$(($x-1))
done
command="$command \\( -fill white -delay 200 $f -scale 205x205 -crop 200x200+0+5 +repage \\)"

for f in source/*.png; do
    command="$command \\( -delay 500 $f -scale 205x205 -crop 200x200+0+5 +repage \\)"
    command="$command \\( -delay 15 $f -scale 205x205 -crop 200x200+0+0 +repage \\)"
done

command="$command -loop 0 output.gif"

echo -e "$command"
eval $command
