Skip to content
Advertisement

Ignore image name while getting hash

I’m coding a program which’ll take an image for an input, check it against images in a database and output the image with the same hash

However, when using hash("imagepath") 2 of the same images give different hashes, even when the only difference is the image’s name, which makes me believe the name is the issue

Is there a way to easily ignore the name of the image? (png)

Advertisement

Answer

How I solved it: I ended up not using “hashing” but the average pixel by scrambeling pieces of code together, and then find an image with the same average pixel (the average pixels are in a list so it gets the index which it then uses to find a name)

JavaScript

This worked for me but it has a few downsides:

  1. The images need to be 100% the same in color (A single pixel off can ruin it)
  2. One of these average pixels can make an infinite amount of images, my database only contained 800 so it still worked (However I had to go from compression to 10×10 to 100×100 to not end up with clones)
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement