image hashing 1

image hashing

>>> from PIL import Image
>>> import imagehash
>>> hash = imagehash.average_hash(Image.open('test.png'))
>>> print(hash)
d879f8f89b1bbf
>>> otherhash = imagehash.average_hash(Image.open('other.bmp'))
>>> print(otherhash)
ffff3720200ffff
>>> print(hash == otherhash)
False
>>> print(hash - otherhash)
36

Here is what the above code is Doing:
1. We import the imagehash module.
2. We open the image test.png and calculate its average hash.
3. We open the image other.bmp and calculate its average hash.
4. We compare the two hashes and print the result.
5. We calculate the hamming distance between the two hashes and print the result.

Similar Posts