Skip to main content

python-libphash

Perceptual image hashing in Python, with the libphash C library inside: find duplicate and near-duplicate images with pHash, dHash, aHash, wHash and five more algorithms.

CI PyPI Python License: MIT

A perceptual hash changes little when an image is resized, recompressed or slightly edited, so comparing hashes finds the copies of a picture among many images; an unrelated picture lands about half the bits away. The package computes nine algorithms in C, decodes JPEG, PNG and WebP with libraries linked into the wheel, and gives the same hash for the same file on every platform, bit for bit libphash's.

Documentation · the theory (algorithms, comparing, choosing a threshold) is on libphash's site.

libphash is its own C library, not pHash.org's (Debian's and Ubuntu's libphash0); the package installs as python-libphash, imports as libphash, and needs nothing but cffi.

pip install python-libphash

Wheels for Linux (x86-64, arm64), macOS (arm64) and Windows (x86-64), CPython 3.10 and later, free-threaded builds included; elsewhere pip builds from source with a C compiler.

import libphash as ph
from libphash import Algorithm

a = ph.hash("photo.jpg")                       # pHash, a 64-bit int
b = ph.hash("photo_copy.jpg")
print(ph.hamming_distance(a, b))               # 0..64 bits differ: 0 for a copy

r = ph.hash("photo.jpg", Algorithm.RADIAL)     # a Digest
print(r.similarity(ph.hash("photo_rotated.jpg", Algorithm.RADIAL)))

results = ph.hash_files(["photo.jpg", "photo_copy.jpg"], threads=0)   # all CPUs

ph.hash() takes a path, encoded bytes, a file object, a numpy array of pixels or a Pillow image; ImageContext computes several hashes of one image and reuses its buffers from image to image; Config holds every setting of libphash and checks it.

From a shell, libphash hash, compare and dupes do the same for files (python -m libphash where the command is not on PATH):

libphash dupes --max-bits 10 ~/Pictures

Scope

Hashes are deterministic and unkeyed: they find the copies of a picture in a collection you control. They are not for moderation, blocklists or checking untrusted input, since anyone who can choose the images can make two pictures hash alike or keep a copy from matching. Decoding files from anywhere is the expected use, and a crash on one is a vulnerability: see SECURITY.md.

Versions

The version is X.Y.Z.N: X.Y.Z is the bundled libphash, N the revision of the binding. Hash values depend on X.Y.Z and the settings only, so pip install "python-libphash==2.0.3.*" keeps a stored collection comparable while taking the binding's fixes. Upgrading from 1.x changes hash values and the API: read MIGRATION.md.

License

MIT, see LICENSE. The wheels include libphash and the libraries it bundles (libjpeg-turbo, libpng, libwebp, zlib-ng, stb_image), each under its own license, carried in the wheel.

Metadata

Release files for python-libphash 2.0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-libphash 2.0.3.0
File Size Uploaded Provenance Actions
python_libphash-2.0.3.0.tar.gz 10.7 MB With provenance Details for python_libphash-2.0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for python-libphash 2.0.3.0
File Actions
python_libphash-2.0.3.0-cp315-cp315t-win_amd64.whl CPython 3.15 CPython 3.15 free-threading Windows x86-64 Details for python_libphash-2.0.3.0-cp315-cp315t-win_amd64.whl
python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
python_libphash-2.0.3.0-cp315-cp315t-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64 Details for python_libphash-2.0.3.0-cp315-cp315t-macosx_11_0_arm64.whl
python_libphash-2.0.3.0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for python_libphash-2.0.3.0-cp314-cp314t-win_amd64.whl
python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64, Linux glibc 2.27+ ARM64 Details for python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
python_libphash-2.0.3.0-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for python_libphash-2.0.3.0-cp314-cp314t-macosx_11_0_arm64.whl
python_libphash-2.0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for python_libphash-2.0.3.0-cp310-abi3-win_amd64.whl
python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
python_libphash-2.0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for python_libphash-2.0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 19.5 MB

Release files / python_libphash-2.0.3.0.tar.gz

Download URL python_libphash-2.0.3.0.tar.gz
Size 10.7 MB
Tags Source
SHA-256 checksum
How to use checksums
d516cdb3c79f315b819f67a348f8a51393c09baef4eafeeb5480033e0a4d5d77
BLAKE2b-256 checksum
How to use checksums
da3ba111a2469db0df11cbf792de0322d8948747d46ae1dc715ac4e5f6d194d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp315-cp315t-win_amd64.whl

Download URL python_libphash-2.0.3.0-cp315-cp315t-win_amd64.whl
Size 535.2 kB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
cda78f2603f135eecec37b27eb39b440732eeb37e6134045d7b3d8fcece85cda
BLAKE2b-256 checksum
How to use checksums
b9f0316aac1f8f20eb3466324a8b3024e4119cda48fff33685f33a5b27aa93dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 914.2 kB
Tags CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
38e5a245cd3c176b91260dce56b47a18d0738ffa36ccf175fd3ade80d1a052e8
BLAKE2b-256 checksum
How to use checksums
1d26b6e3467f69a9fbf36760a66ea3d4d99a14bc5bdfd7903f0b37568a141e17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL python_libphash-2.0.3.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 838.8 kB
Tags CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
ef6a766c705462f3bbd36aee8f099a7733e54d2e33f98b22b8521dbe1c3c8958
BLAKE2b-256 checksum
How to use checksums
14494288a98eb9db8da0ab93e03ad366b4fc05b27e2874ca3b144d1ae1b65598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp315-cp315t-macosx_11_0_arm64.whl

Download URL python_libphash-2.0.3.0-cp315-cp315t-macosx_11_0_arm64.whl
Size 632.3 kB
Tags CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
cd68f12541dc6f2f2f73ac61814d5c6aa0dab6dd635dc918da8b2d66f7477e3b
BLAKE2b-256 checksum
How to use checksums
bb2b7171c456c9252fd2d0333081e3176622a7b25aca48faef179f67d9f8e29f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp314-cp314t-win_amd64.whl

Download URL python_libphash-2.0.3.0-cp314-cp314t-win_amd64.whl
Size 535.3 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
abd7574f0f61bfe5232eb0dad1f49fa7a0aadb35f2a77f7c9157a926f0f351c2
BLAKE2b-256 checksum
How to use checksums
dd5ceaf2871e92e1c82b3c813b20e7fc3b43004c089838102046a5170dcd3045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 919.4 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f4a82c6e70c2b8ceb6a73a41e8a83ff9e9e89a68a9bc73b251a6d91c3a5d88eb
BLAKE2b-256 checksum
How to use checksums
a9772979c772524cfcc0a2e689c58fc97d6e163ff051fa2d9857182b2d9e1b0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL python_libphash-2.0.3.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 844.2 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
01a77e5210fcd01300879c9697db8898fe99d52a8010b6a2728187b9c3c00009
BLAKE2b-256 checksum
How to use checksums
a1a1c86e8602a9c22b8b22bdf3ff5a6094704b12a868ed4b383f9de0bdbc4705
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp314-cp314t-macosx_11_0_arm64.whl

Download URL python_libphash-2.0.3.0-cp314-cp314t-macosx_11_0_arm64.whl
Size 632.5 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b4cc616ecb4dc2fe942bec6e2e13764919e6ca850c9eb30e5fd9b8c957dc79d3
BLAKE2b-256 checksum
How to use checksums
3276bc64aeb182c37fefa2897c3d0ad01fc1f1d11cec5510ca44982a4f64e007
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp310-abi3-win_amd64.whl

Download URL python_libphash-2.0.3.0-cp310-abi3-win_amd64.whl
Size 518.9 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
732167049e8fae9e92ff7d6424d76244d4a399bb80ec44d47fa7e85dc8470a24
BLAKE2b-256 checksum
How to use checksums
758821ae4f33d8838e4f35a7968b16a884d52992550c0359a3314354aa54194a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 913.6 kB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
8a3f9f278be1805e7a758c8135f2c4cf9e2240fe2afa2077747b5c555dbe233d
BLAKE2b-256 checksum
How to use checksums
63555438a57672ffc76c6b9aac5929deacd7b42b87f1d425212cf8b1a2788026
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL python_libphash-2.0.3.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 838.1 kB
Tags CPython 3.10 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
bee39966b312f156550f38e2b7ed8626110739449b9b94783a6ccbec9a1f60d1
BLAKE2b-256 checksum
How to use checksums
77c3a5e8bea4de70c0b41193fef87770de61b0a92bab7b0375f03a83414decca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / python_libphash-2.0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL python_libphash-2.0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 632.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ec1c5ac3aa76d665d6754e18093ed53116c72c77e6d8522c7a7b8b2a3e43f376
BLAKE2b-256 checksum
How to use checksums
c2d0fa95db5156874c05b2f4c6a087865b3c80f4b1c3f19750b4dc950c03540d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for python-libphash 2.0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 13 files in this release have been uploaded with provenance metadata.

Select from 13 files

Attestation for python_libphash-2.0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page