Skip to content

Instantly share code, notes, and snippets.

@dmpetrov
Created March 6, 2017 04:26
Show Gist options
  • Save dmpetrov/46a47557d52f9c44001de1d629619b8d to your computer and use it in GitHub Desktop.
Save dmpetrov/46a47557d52f9c44001de1d629619b8d to your computer and use it in GitHub Desktop.
Perceptual image hashing
# Code for the blogpost https://fullstackml.com/2016/07/02/wavelet-image-hash-in-python/
import PIL
from PIL import Image
import imagehash
hash1 = imagehash.phash(Image.open(‘test1.jpg’))
print(hash1)
# > 354adab5054af0b7
hash2 = imagehash.phash(Image.open(‘test2.jpg’))
print(hash2)
# > 5b7724c8bb364551
hash1 == hash2
# > False
hash1 – hash2
# > 44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment