#!/usr/bin/perl
#
# convert_frames.pl

use Image::Magick;

$imgdir = "frames";
$prefix = "pyode_ex3";

$| = 1;

while ($infile = <$imgdir/$prefix.*.tif>) {
    print "$infile -> ";
    ($outfile = $infile) =~ s/\.tif$/.png/;

    $image = Image::Magick->new;
    $x = $image->Read($infile); warn "$x" if ($x);
#    $x = $image->Crop(geometry=>'640x360+0+30'); warn "$x" if ($x);
#    $x = $image->Crop(geometry=>'1280x720+0+60'); warn "$x" if ($x);
    $x = $image->Crop(geometry=>'1280x720+0+180'); warn "$x" if ($x);
    $x = $image->Write($outfile); warn "$x" if ($x);

#    unlink($infile);
    print "$outfile \n";
}
