python bindings for pHash
Pull request Compare This branch is 1 commit ahead, 20 commits behind polachok:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Python bindings for libpHash (

A perceptual hash is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions which rely on the avalanche effect of small changes in input leading to drastic changes in the output, perceptual hashes are "close" to one another if the features are similar.


python install


DCT hash

int phash_imagehash( str file ) int phash_distance( int hash1, int hash2 )

Radial hash

pHash.Digest phash_image_digest( str file, float sigma, float gamma, int angles=180 ) int phash_crosscorr( phash.Digest digest1, phash.Digest digest2 )

import pHash
hash1 = pHash.phash_imagehash( 'file.1.jpg' )
hash2 = pHash.phash_imagehash( 'file.2.jpg' )
print 'Hamming distance: %d (%08x / %08x)'
  % ( pHash.phash_hamming_distance( hash1, hash2 ), hash1, hash2 )

digest1 = pHash.phash_image_digest( 'file.1.jpg', 1.0, 1.0, 180 )
digest2 = pHash.phash_image_digest( 'file.2.jpg', 1.0, 1.0, 180 )
print 'Cross-correlation: %d'
  % ( pHash.phash_crosscorr( digest1, digest2 ) )


  • Return peak cross-correlation for radial hashing
  • Add audio and video support
  • Beautify the code, add comments