Hi:

I would like my script to compare two images and tell me if even one single pixel is slightly different in one of them. Also tell me if its width or height is different too.

Is there a library which already does this..??

I know about the file test operators. (-T for text files, -B for Binary, -s for size, -M last modified in days, -A last accessed in days), but I havent found any operator which can tell me if the pixels or width or height have been changed.

So far, besides using the test operators above, I'm opening both binary files , reading them into memory and comparing the output... but ofcourse this is not good enough I need better suggestions.

open (IMAGE1, "<image1.jpg") || die print"cant open image1.jpg"; $results1 = <IMAGE1>; close (IMAGE1); open (IMAGE2, "<image2.jpg") || die print"cant open image2.jpg"; $results2 = <IMAGE2>; close (IMAGE2); if ($results1 eq $results2){ print"both images are the same"; }

If you can help.. I'll appreciate it


In reply to Matching Images by virtualweb

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.