363,925 Members | 2615 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Compare Images

Nitro
P: n/a
Nitro
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.

Apr 7 '06 #1
Share this Question
Share on Google+
2 Replies


BLob
P: n/a
BLob
> Does anyone know a simple way to compare two images to see if they are[color=blue]
> 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.[/color]

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";
}
[color=blue]
> The files will be jpeg images.[/color]

The md5 should work for any type of file.

BLob


Apr 7 '06 #2

no-1
P: n/a
no-1
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
files.

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

or:
http://news.cnet.co.uk/digitalcamera...9257088,00.htm
www.riya.com

Apr 7 '06 #3

Post your reply

Help answer this question



Didn't find the answer to your PHP question?

You can also browse similar questions: PHP