Use of compare in Perlmagick (create diff image)
Posted: 2009-07-09T09:55:00-07:00
I have a script running the compare utility in Perlmagick. I am able to get the error but how do I generate the "diff image". For instance in the command line interface I would write
compare -metric mae refImage.png checkThisImage.png diff.png
to do comparison between the refImage.png and checkThis.png images, with their difference pixels going into a file called "diff.png". How do I use Perlmagick to generate diff.png. Further, is there an interface spec somwhere that defines how to use compare and other utilities? For instance the Get function/method in the script below: Is there a doc that spells out usage of this and other functions/methods?
The script I'm using now is
-----------------------------------------------------------------------------
use Image::Magick;
$i1 = Image::Magick->new;
$i2 = Image::Magick->new;
$w = $i1->Read( filename=>'imgref.PNG'); # read in images
warn("$w") if $w;
exit if $w =~ /^Exception/;
$w = $i2->Read( filename=>'imgSmallDiff.PNG');
warn("$w") if $w;
exit if $w =~ /^Exception/;
$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'));
-------------------------------------------------------------------------------
compare -metric mae refImage.png checkThisImage.png diff.png
to do comparison between the refImage.png and checkThis.png images, with their difference pixels going into a file called "diff.png". How do I use Perlmagick to generate diff.png. Further, is there an interface spec somwhere that defines how to use compare and other utilities? For instance the Get function/method in the script below: Is there a doc that spells out usage of this and other functions/methods?
The script I'm using now is
-----------------------------------------------------------------------------
use Image::Magick;
$i1 = Image::Magick->new;
$i2 = Image::Magick->new;
$w = $i1->Read( filename=>'imgref.PNG'); # read in images
warn("$w") if $w;
exit if $w =~ /^Exception/;
$w = $i2->Read( filename=>'imgSmallDiff.PNG');
warn("$w") if $w;
exit if $w =~ /^Exception/;
$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'));
-------------------------------------------------------------------------------