Upload check

Hey guys,

i have an application where i can upload images to a server and others can upload pictures on it too.

but sometimes two people upload the same picture…

how can i check if the picture is already on the server with a command that say it’s true or false?

i would be very thankful for any help here guys
thanks to you all

You could hash the image with MD5 or similar and store that along with the picture. Then whenever a new picture is uploaded, compare the MD5 hashes and only store it if different.

This assumes people are actually uploading the same image file for some reason. Not just a picture of the same thing. If you wanted to screen out pictures of the same subject, then you’d need an AI of some sort or a quite sophisticated image detection algorithm. If you could build one of those that worked well, google or somebody would probably pay you big bucks for it.

If the image will have a public address you can check if the resource exists with a http request.

If your upload method use a script on the server (php for example) you could write a script that return a json if the file exists (you know your rule to check if the file is the same: same hash, same name, same color on a pixel). again an http request with the parameters you need to check this existence

@Kevin Windham

i don’t want to check if a picture is added, i just want to check if the picture is already uploaded with true or false.

not checking on the changes of the image, just the engagement of the image

You can use the MD5 or any of Antonio’s methods to see if the file is exactly the same as one that’s been previously uploaded. If you’re trying to match image content, you’ll need a service like https://tineye.com/products

@Dante Neumann

So I guess I am not sure what the actual usage is. Are you saying your code is uploading an image to a server that you don’t control, but before uploading you want to check if the image is already there?

In that case you could check if a file of the same name and size is already there using a list command or whatever option is available on the server you’re uploading to.

If you don’t control the server though then your options may be limited. Maybe you could be more specific about your application and how it works so we could give you better guidance.

the usage is to make sure the image you upload isn’t the same

I give up. Best of luck.

Dante, you’ll have to create a method somewhere that compares the pictures in some way, but that depends on your requirements. That requires a better understanding of your definition of “the same”.

  • identical, as in the same exact file, taken from the exact source and hasn’t been altered in any way.
  • similar, identical, but perhaps resaved (because that can cause pixels to change if a new profile, format or compression setting is applied.
  • content, they both have the same subject, like Cats.

These three are increasingly difficult as others have indicated, but until you define the level of “same-ness” you are after, no one here can even begin to guide you.

FWIW, in Xojo all of these require uploading the image before you can tell anything.

it’s solved, thx