TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Different Hashes for same Image (http://www.talkphp.com/advanced-php-programming/6335-different-hashes-same-image.html)

spring 07-27-2012 07:26 PM

Different Hashes for same Image
 
I have two identical images stored in two different servers (dropbox and my own).
however, i realize that

hash("md5",file_get_contents($image1))
hash("md5",file_get_contents($image2))


are returning different hashes for these identical images.
How can i make sure they both return the same string?

tony 07-29-2012 05:27 AM

Have you tried hash_file? to see if you get the right results.

I am not sure why it would give you different values though, have you tested it with other images files from different sources. I tried it myself with dropbox and local copies and hash and hash_file work as they are supposed to.

spring 08-01-2012 02:35 PM

Thanks tony,

I looked at the images again, and they were not the same. One of the thousands of pixels had a rgb value that was off by one from the other image. I've been using hash md5 now and it works fine.

Is there a way to make hashes so that they dry similar images will have the same hash value? Or should I just use a hash encoder that returns a shorter hash string then, like something other than md5?

tony 08-05-2012 12:04 AM

There are algorithms out there for that. Specially for image caching for search engines like google. I am not familiar with those algorithms, Maybe there is a library that you can use or port to PHP to use.

Edit: This is the closest thing I could find quick, probably a starting point.


All times are GMT. The time now is 02:54 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0