'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)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source