WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Image Comparison


Question:

I need to compare two images and determine if they are equal. I wanted to do a byte size comparison but each one of my images are exactly the same size, type, and bit depth even though each image is different. I thought I could write down the byte count of each one of the images and compare them with the new one but maybe that is not not the way to do it. Any ideas on how I can do this in Winbatch? Any help would be greatly appreciated.

Answer:

Use the imgCompare function in Pixie Extender or read the entire image file into a binary buffer (BinaryRead) and then use BinaryCheckSum() to generate the MD5 hash of the buffer contents. Do this for each file and then compare the hashes. If the contents of any two files differ by even a single bit then the MD5 hash values will be different.

It would probably be worth it to do some testing to see which method is more efficient. Using ImgCompare() will give results of varying degrees of sameness or differences between images based on an algorithm that does some sort of [sophisticated] comparision of the images. The MD5 hash method will simply perform a brute-force number crunching algorithm to get the hash value. If the images even differ by a single bit [either different values or different file sizes] then the MD5 hash values will be different.

The two different methods would be appropriate for different applications. If you have a whole bunch of image files on disk and think that some of them are simply copies of the same file under different names then the MD5 hash method would probably be the fastest. If you have a group of image files that you think are slightly different variants of each other and you want to determine how similar they are, then the ImgCompare() method will tell you what you want to know but I suspect that it will take more CPU cycles to perform those comparisons.


Article ID:   W15983
File Created: 2004:03:30:15:42:06
Last Updated: 2004:03:30:15:42:06