Compare Images

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Does anyone know a simple way to compare two images to see if they are
the same? The filenames of the images will be different, but if the
image data is the same I would like to test for that.

The files will be jpeg images.

Re: Compare Images

Quoted text here. Click to load it

Just compare the md5 codes of the two files :

if (md5(file_get_contents($filename01)) ==
md5(file_get_contents($filename02))) {
    echo "The files are the same";
} else {
    echo "The files are not the same";

Quoted text here. Click to load it

The md5 should work for any type of file.


Re: Compare Images

do you mean, are the files from the same original source? or do they
"look" the same?

You could use an OS level cmp (compare) utility -- Four Unix utilities,
cmp, comm and diff/sdiff, can be used to compare the contents of two

to see if they "look" the same requires special recognition software
that - generally speaking - only governmental agencies can afford.


Site Timeline