A hash seeded with something static (like a file name or the actual file) will tell you whether there's an exact match, but it won't help you with similarity, as hashes will diverge significantly even with minor changes. So you have two options:
1. Ignore the problem...
...and just ensure files don't collide with each other, even if they're duplicates (Fastest).
This is where hashes come in handy: seeding a hash with something relatively unique virtually ensures the ability to uniquely reference a file, even if its file name is the same or the image is similar. The value of this, especially in an image board, is for CDNs: most CDNs generally determine duplicates based off of file name (because it's fast). So if someone makes a modification to an image but uses the same file name, the CDN will ignore the new version.
So, if your file name is foo.jpg
, you could create a hash using something like
list(basename, extension) = split(filename, '.')
hash = md5(filename . ':' . time())
filename = basename . '_' . hash . extension
And arrive at something like foo_a23aed3a298ae.jpg
. Since the base name and the extension doesn't change, it'd be trivial to generate the original file name.
Plus, as the hash was seeded with the time, you should have a mostly unique hash, even when the two files are mostly the same.
2. Compute the image similarity criteria once...
...and store the results in the image's metadata or a separate database (Slower, but higher chance of saving storage).
This would go hand-in-hand with the first option.
Any good image library will provide a wealth of data about an image that you could use to create a comparison formula between two images. You'd then store those data either in the image itself (accessible via metadata like EXIF or IPTC) or in a database referenced by the image's unique hash.
Of course, in this scenario, you're doing searches throughout your database for matches. You might save some time by adding the important metadata to the file name:
foo_200x200_300dpi_cats_a23aed3a298ae.jpg
But depending on the amount of images you have to sort through, this can be really expensive, and would likely outweigh the cost of additional storage.