in reply to compare images with perl 5.6 or 5.8

You can use ImageMagick's compare. See PerlMagick page and search for Compare to do it in Perl. In shell, it would go something like
compare -metric mae image.png reference.png difference.png
in Perl, I havn't figured out the right syntax. If you do, please post it.

Update: I found this on Google. The shell compare returns an image with red pixels where the diff's are. Apparently, Compare in PerlMagick just returns some statistics like the following returns:

Errors is 3156.326700 Mean Error is 0.026116

#!/usr/bin/perl use warnings; use strict; use Image::Magick; my $i1 = Image::Magick->new; my $i2 = Image::Magick->new; my $w = $i1->Read('image.png'); # read in images warn("$w") if $w; exit if $w =~ /^Exception/; $w = $i2->Read( 'reference.png'); warn("$w") if $w; exit if $w =~ /^Exception/; $i1->Scale(width=>100, height=>100); # scale without preserving aspect + ratio $i2->Scale(width=>100, height=>100); $w = $i1->Compare(image=>$i2); # compare die "$w" if $w; printf "Errors is %f\n", $i1->Get('error'); printf "Mean Error is %f\n", $i1->Get('mean-error');

UPDATE2: Found a way with the Difference option of Composite, to produce a visual diff.

#!/usr/bin/perl use warnings; use strict; use Image::Magick; my $i1 = Image::Magick->new; my $i2 = Image::Magick->new; #make some test files $i1->Set(size=>'250x100'); $i1->ReadImage('xc:white'); $i1->Draw(primitive=> 'rectangle', fill=>'red', points=>'60,30 110,70'); $i1->Write("i1.png"); #for comparison $i2->Set(size=>'250x100'); $i2->ReadImage('xc:white'); $i2->Draw(primitive=> 'line', fill=>'green', points=>'10,10 200,100'); $i2->Write("i2.png"); #for comparison $i1->Composite( gravity => "Center", compose=>'Difference', image => $i2, ); $i1->Write("$0-diff-compose.png");

I'm not really a human, but I play one on earth Remember How Lucky You Are