dHashPy
Row-wise gradient dHash algorithm in python.
dHash algorithm was originally described at Kind of Like That - The Hacker Factor Blog
Installation
- Using pip:
pip install dhashpy -U
- Install directly from GitHub:
pip install git+https://github.com/akamhy/dhashpy.git
Usage
>>> from dhashpy import DHash
>>> file = "/home/akamhy/Pictures/map_of_maths.png"
>>> dhash_file = DHash(file)
>>> dhash_file
DHash(hash=0b0110010000000011101010111100110111001101100011111000111100001110, hash_hex=0x6403abcdcd8f8f0e, path=/home/akamhy/Pictures/map_of_maths.png)
>>>
>>> dhash_file.hash # A 64-bit hash, notice the prefix "0b" indicating it's binary. Total string length = 64 + 2 = 66
'0b0110010000000011101010111100110111001101100011111000111100001110'
>>>
>>> len(dhash_file)
66
>>> dhash_file.bits_in_hash
64
>>>
>>> dhash_file.hash_hex
'0x6403abcdcd8f8f0e'
>>>
>>> dhash_file - "0x6403abcdcd8f8f0e"
0
>>>
>>> dhash_file == "0x6403abcdcd8f8f0e"
True
>>>
>>> dhash_file - "0b0110010000000011101010111100110111001101100011111000111100001110"
0
>>>
>>> dhash_file
dhash_file
>>> dir(dhash_file)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__weakref__', 'bin2hex', 'bits_in_hash', 'calc_hash', 'hamming_distance', 'hash', 'hash_hex', 'height', 'hex2bin', 'image', 'path', 'width']
>>> dhash_file.height
8
>>> dhash_file.width
9
>>> dhash_file.image
<PIL.Image.Image image mode=L size=9x8 at 0x7F9D324C0580>
>>>
License
Released under the MIT License. See license for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dhashpy-1.0.2.tar.gz
(8.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dhashpy-1.0.2.tar.gz.
File metadata
- Download URL: dhashpy-1.0.2.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fff2be22be76a0de1f570ebf089ebfc9eb1a3be6242ddeb4cc1c63ecd57860e8
|
|
| MD5 |
9110b462131bbd7800995b8d9338008b
|
|
| BLAKE2b-256 |
684daa90251b5d055811b11a87e548188043c0727adb37f5679d9d5bea931aaa
|
File details
Details for the file dhashpy-1.0.2-py3-none-any.whl.
File metadata
- Download URL: dhashpy-1.0.2-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0db07b226137a0526125e7666b02594ddbb12724c29dfe725b192dce1a207f6d
|
|
| MD5 |
f8ee0615d7255b237c87bc6cfc3f246c
|
|
| BLAKE2b-256 |
b39f723bdd462eced7d06ec4fcbec0f94006bc226d2c89498e3efbf64c4d65f1
|