 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
08-19-2009, 10:43 AM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
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.
__________________
|
|
|
|
08-19-2009, 10:54 AM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
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.)?
|
|
|
|
08-19-2009, 12:00 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
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.
__________________
|
|
|
|
08-19-2009, 12:13 PM
|
#4 (permalink)
|
|
The Wanderer
Join Date: Aug 2009
Posts: 11
Thanks: 1
|
<?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. :)
|
|
|
|
|
The Following User Says Thank You to jasonberresford For This Useful Post:
|
|
08-19-2009, 03:14 PM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
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..
__________________
|
|
|
|
08-19-2009, 03:22 PM
|
#6 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by Tanax
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..
|
No, the function used is md5_file which creates an MD5 hash of the binary contents of the file, not the file name.
|
|
|
|
|
The Following User Says Thank You to Salathe For This Useful Post:
|
|
08-19-2009, 04:20 PM
|
#7 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by Tanax
I didn't understand the part "cater for different copies" - my english vocabulary is not perfect.
|
Don't feel bad, I have no idea what that meant either.
|
|
|
|
08-19-2009, 05:15 PM
|
#8 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
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.
|
|
|
|
08-19-2009, 07:04 PM
|
#9 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
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() ?
__________________
|
|
|
|
08-19-2009, 07:14 PM
|
#10 (permalink)
|
|
The Wanderer
Join Date: Aug 2009
Posts: 11
Thanks: 1
|
Yes it's just fine, because any changes to that image would result in a different MD5
|
|
|
|
08-19-2009, 07:26 PM
|
#11 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
Quote:
Originally Posted by Salathe
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.
|
Extremely.
|
|
|
|
08-19-2009, 08:49 PM
|
#12 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by jasonberresford
Yes it's just fine, because any changes to that image would result in a different MD5
|
Right.. that's great 
But if they only change the name of the file, it will still have the same MD5 hash, right? ^_^
__________________
|
|
|
|
08-19-2009, 08:55 PM
|
#13 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
Quote:
Originally Posted by Tanax
Right.. that's great 
But if they only change the name of the file, it will still have the same MD5 hash, right? ^_^
|
Yup. ( Char Limit )
|
|
|
|
08-19-2009, 09:53 PM
|
#14 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Great, thanks everyone!
__________________
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|