#!/usr/bin/perl
#


$debug = 1;
$temp1 = "foo.jpg";
$temp2 = "foo2.jpg";

@files = glob("jup_????.png");
foreach $file (@files) {

  printf "next is %s \n", $file;
  $new_name = $file;
  $new_name =~ s/jup_/crop_/;

  $cmd = "convert $file $temp1";
  $ret = exec_cmd($cmd);

  $cmd = "convert -crop 700x300+250+250 $temp1 $temp2";
  $ret = exec_cmd($cmd);

  $cmd = "convert $temp2 $new_name";
  $ret = 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);
}


