|
import copy
|
|
|
|
import pHash
|
|
|
|
class Image(object):
|
|
|
|
def __init__(self, path, hash=None, coefficients=None):
|
|
self.path = path
|
|
|
|
if not hash:
|
|
self.hash = pHash.imagehash(self.path)
|
|
else:
|
|
self.hash = hash
|
|
|
|
if not coefficients:
|
|
self.coefficients = copy.copy(pHash.image_digest(self.path, 1.0, 1.0, 180).coeffs)
|
|
else:
|
|
self.coefficients = coefficients
|
|
|
|
def make_digest(self):
|
|
digest = pHash.Digest()
|
|
digest.coeffs = copy.copy(self.coefficients)
|
|
digest.size = len(self.coefficients)
|
|
return digest
|
|
|
|
def __repr__(self):
|
|
print 'Image: {:s}'.format(self.path)
|
|
print '\tHash: {:016X}'.format(self.hash)
|
|
print '\tDigest coefficients: {:s}'.format(str(self.coefficients))
|