Compare two images
Moderator: General Moderators
Compare two images
Hi all,
Could someone help me? I want to know if I can compare two images pixel by pixel by using php.
Thank you
Could someone help me? I want to know if I can compare two images pixel by pixel by using php.
Thank you
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
Not tested, probably wont work:
Edit thanks to AC
Code: Select all
if (md5_file($image1) == md5_file($image2)) {
//images are equal
} else {
//images are not equal
}
Last edited by nickvd on Fri Aug 18, 2006 8:11 pm, edited 1 time in total.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
That's what I'd do, except I'd use md5_file() to avoid loading the images into memory. 
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Compare filesize() first, if you're going to run that. If they're different sizes, what's the point of running md5()? 
Thank you,
Actually, I want to know the code to put it in my forum. When vistors register in my forum, they enter their image like password. Their image will be in the database. If they want to use my forum, they should enter their image after that the code will compare two images.
Is ti possible?
Again, thank you
Actually, I want to know the code to put it in my forum. When vistors register in my forum, they enter their image like password. Their image will be in the database. If they want to use my forum, they should enter their image after that the code will compare two images.
Is ti possible?
Again, thank you
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
A little strange, but okay... I'd suggest the SHA256 library then. If you don't understand it, I would suggest sha1()/sha1_file() over md5()/md5_file(). I would only store the hash result. Storing the image itself is silly.
And double hashing is less secure; just so you know before you try it.
And double hashing is less secure; just so you know before you try it.