Hi, I am using the Image::Compare module to compare two images and here is my code

sub CompareImage{ print " CompareImage function called"; my @args = @{$_[0]}; print "Arguments:".@args[0]; print "Arguments:".@args[1]; my($cmp) = Image::Compare->new(); $cmp->set_image1( img => '@args[0]', ); $cmp->set_image2( img => '@args[1]', ); $cmp->set_method( method => &Image::Compare::THRESHOLD, args => 25, ); if ($cmp->compare()) { print 'The images are the same, within the threshold'; return 'PASS'; } else { print 'The images differ beyond the threshold'; return 'FAIL'; } }

I am triggering this function from a different file and i am passing an array reference which holds the images to be compared(absolute path to the image files). I am accessing the images using the indexes and itseems to be failing during the comparison, when i print the content of the array i am getting the correct values but if i use it a comparison it fails, however if i hardcode the path values the function works fine. I am getting the below error with the above usage.

CompareImage function called Arguments:D:\\img1.jpg Arguments:D:\\img2.jpg Unable to read image data from file '$args[0]': 'Could not open $args[0]: No such file or directory' at C:/strawberry/perl/site/lib/Image/Compare.pm line 162. Can anyone help me resolve the issue.


In reply to Problem with Image::Compare module. by balajinagaraju

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.