Skip to main content

A Python Perceptual Image Hashing Module

Project description

This was mainly created just for my own use and education. It’s a perceptual hash algorithm, used to find if two images are similar.


Returns the hash of the image using an average hash algorithm. This algorithm compares each pixel in the image to the average value of all the pixels.:

import photohash
hash = photohash.average_hash('/path/to/myimage.jpg')


Returns the hamming distance between the average_hash of the given images.:

import photohash
distance = photohash.distance('/path/to/myimage.jpg', '/path/to/myotherimage.jpg')


Returns a boolean of whether or not the photos look similar.:

import photohash
similar = photohash.is_look_alike('/path/to/myimage.jpg', '/path/to/myotherimage.jpg')

is_look_alike also takes an option tolerance argument that to define how strict the comparison should be.:

import photohash
similar = photohash.is_look_alike('/path/to/myimage.jpg', '/path/to/myimage.jpg', tolerance=3)


  • Add more hash algorithms.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PhotoHash-0.1.0.tar.gz (2.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page