Is there any simple way to test two PNGs for equality?

Posted by Mason Wheeler on Stack Overflow See other posts from Stack Overflow or by Mason Wheeler
Published on 2010-03-21T18:45:58Z Indexed on 2010/03/21 18:51 UTC
Read the original article Hit count: 350

Filed under:
|
|

I've got a bunch of PNG images, and I'm looking for a way to identify duplicates. By duplicates I mean, specifically, two PNG files whose uncompressed image data are identical, not necessarily whose files are identical. This means I can't do something simple like compare CRC hash values.

I figure this can actually be done reliably since PNGs use lossless compression, but I'm worried about speed. I know I can winnow things down a little by testing for equal dimensions first, but when it comes time to actually compare the images against each other, is there any way to do it reasonably efficiently? (ie. faster than the "double-for-loop checking pixel values against each other" brute-force method?)

© Stack Overflow or respective owner

Related posts about png

Related posts about algorithm