I have done something very similar under windows, but used
ImageMagick instead of GIMP. ImageMagick has code built in for the comparison part. Here are some code snippets to give you some ideas:
# http://www.imagemagick.com/
use Image::Magick;
use Win32::Screenshot; # to capture screenshots directly into image
+magick bjects:
sub Capture_Screen {
@$image = ();
$image = CaptureScreen( );
die "FAILED: Capture-Screen\n" unless ( defined $image );
# my ($w, $h) = $image->Get('columns','rows'); print "Captured: $
+w,$h\n";
$image->Set(matte=>'False');
# $image->Write('captured_scr.bmp');
}
sub Capture_Area {
$image2 = CaptureRect( 10,730,190,11 );
die "FAILED: Capture-Screen\n" unless ( defined $image2 );
}
sub Get_Predefined_Images {
# reading predefined images from disk into a hash:
for my $nm ( qw( )) {
$dsk_img{$nm} = Image::Magick->new(magick=>'bmp');
my $bmp_nm = "IMG_" . $nm . '.bmp';
$x = $dsk_img{$nm}->Read($bmp_nm);
warn "$x" if "$x";
}
}
sub Compare_Area {
my $wca_img = CaptureRect( $x,$y,35,13 );
die "FAILED: capture-rectangle\n" unless ( defined $wca_img );
# $cmp_img is image to compare against.
$xx = $wca_img->Compare( image => $cmp_img );
warn "Status_Img: $xx" if "$xx";
my $result = $wca_img->Get('mean-error');
# $result is 0 or near zero when images match.
return(1) if $result == 0;
}