![]() |
ImageGD
Hey!
I'm just wondering.. is it possible to check if 1 image is the same as another image? So I can prevent members from uploading the same image several times. |
You could just take an MD5 hash of each file and if they are literally the same image then the hashes will match. Or are you wanting to cater for different copies of the same image (sizes, file types, etc.)?
|
I didn't understand the part "cater for different copies" - my english vocabulary is not perfect.
Anyhow, what I want is that I want them to only be able to upload the same image ONCE. However, if they for example crop the image, the image won't be the same(though the object will probably be the same - but it's not the same image), they will be able to upload that. What I mean is basically I want to run a check if they already uploaded the FILE once before. But since they can change the filename in the case - using the filename is not the best option for me.. if you understand what I mean? I really hope I'm explaining this so you understand. |
<?php
$file = 'image.jpg'; $filemd5 = md5_file($file); When inserting the image, insert with the md5 .. when a new image is inserted check the database for the existing md5.. if it's not there .. insert, if it is .. don't. :) |
Yes, I understood that part. Problem with that is if they change the name of the file, they will be able to upload the exact same image, only it's another name..
|
Quote:
md5_file which creates an MD5 hash of the binary contents of the file, not the file name. |
Quote:
|
By "different copies" I quite simply mean the same image but saved at slightly different sizes, crops, file formats, quality settings, etc.. That's a little trickier than looking for exact file matches.
"To cater for/to" is a turn of phrase, I've no idea how widespread its use is. |
Thanks alot!
One question though. I want people like.. they should be able to upload a original photo, and then if they use some filters or effects on that photo in .. for instance Photoshop, they should be able to upload that edited picture. That is still possible if I use the md5_file() ? |
Yes it's just fine, because any changes to that image would result in a different MD5
|
Quote:
|
Quote:
But if they only change the name of the file, it will still have the same MD5 hash, right? ^_^ |
Quote:
|
Great, thanks everyone!
|
| All times are GMT. The time now is 09:42 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0