#!/usr/bin/perl
#
# 

$debug = 1;

$start = 676;
$end = 694;
$geometry = "400x400+940+550";

if (1 == 1) {
for ($i = $start; $i <= $end; $i++) {

  $file = sprintf "DSC_%04d.JPG", $i;
  $temp = sprintf "temp_%04d.jpg", $i;
  $cmd = sprintf "convert -extract $geometry $file $temp";
  exec_cmd($cmd);
  $temp2 = $temp;
  $temp2 =~ s/jpg/gif/;
  $cmd = sprintf "convert $temp $temp2 ";
  exec_cmd($cmd);

}
}


$cmd = "~/old/bin/gifmerge ";
for ($i = $start; $i <= $end; $i++) {
  $temp = sprintf "temp_%04d.gif", $i;
  $cmd .= " $temp ";
}
$cmd .= " > fringe_anim.gif";
exec_cmd($cmd);


exit 0;



##############################################################################
# PROCEDURE: exec_cmd
#
# DESCRIPTION: Execute the given shell command line.  If the $debug flag
#              is set, we print to stdout the command line, and
#              also print out the result string.
#
# RETURNS:
#              the result of the command
#
#
sub exec_cmd {

  my($cmd, $ret);

  $cmd = $_[0];

  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;
  if ($debug > 0) {
    printf "ret is ..$ret.. \n";
  }

  return($ret);
}


