Skip to main content

python-libphash

Perceptual image hashing in Python, with the libphash C library inside.

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.

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.1.*" 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.1.1

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.1.1
File Size Uploaded
python_libphash-2.0.1.1.tar.gz 10.7 MB Details

Built distributions (wheels)

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

Total release size: 19.4 MB

Release files / python_libphash-2.0.1.1.tar.gz

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

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp315-cp315t-win_amd64.whl
Size 533.7 kB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
4fadb1c4afbd007afff07e5b223df0b08fb14ed9f2f2caa2e752c3d8d1bd9209
BLAKE2b-256 checksum
How to use checksums
2471962336cf341b6e198623daef0bc623d466c8d53202a0b3421cc1773c884d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 912.9 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
3d0845b33ecdd9b2b63eb473fef409148460af2dc512146d568faa6f066489bd
BLAKE2b-256 checksum
How to use checksums
1fb705f40e4652bd1eda8ed2cc89d359774750575cfd309858ce89d966ee555b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 837.5 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
5478e0dfb10286a647214ab6cfe9e717e3cf28be50e46228fa4c513a714c2503
BLAKE2b-256 checksum
How to use checksums
f6618f8d076d21cc148cf4b8e1754b1ed8194d3e1dcd580ab832e115755b3512
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

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

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp314-cp314t-win_amd64.whl
Size 533.8 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
1997e3dfb051a0877d1be3929776252b69424054906b31f7a556aaa3cd9fc733
BLAKE2b-256 checksum
How to use checksums
21e343afc67565d9363e38b7b1789f91468f0c12642a82c792190532031817d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 917.7 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
ad213e8d6da58413980aebd13e5311b769d6434df006f0869205444798312779
BLAKE2b-256 checksum
How to use checksums
03c786dc294fcc207fd22666999fab8d2f054b8e980b664f858e404eae0aa307
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 843.1 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
9c5c4fe75b8450a3c991d9ea08f45e84298f4917ff4ab6cabd9f02d6fe3853b2
BLAKE2b-256 checksum
How to use checksums
21798e7109abb74c9682a3faaa87381001dfbce3740ed504812aac90871105e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp314-cp314t-macosx_11_0_arm64.whl
Size 630.5 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
35a915cefc22cad82efd3ecd56f83f263ea35015f9919c4b8ed426b29e98d6d7
BLAKE2b-256 checksum
How to use checksums
912e49b72310591f080587d2b26a7dfbbe2f9aa91aa0552df1da1ef914653e4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp310-abi3-win_amd64.whl
Size 517.3 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7852d29e6e05d6a924e86bcde50a442ea402dcb453b031fd6213a3020396b8f6
BLAKE2b-256 checksum
How to use checksums
69cb6cc2849967bdd7f4d1c81184b90025f02a3de6932e134d2f3e348004b205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 912.1 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
3a008d88252fcb85df414674c36ac5371c998b99f3b82d33be8afb49295fce7a
BLAKE2b-256 checksum
How to use checksums
cba1f342727b2f9d548433e734b8a71f4042ba00e1ca8292510f815e7e668261
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 836.7 kB
Tags CPython 3.10 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
cf78340b7106230e356f1e54bb558148c82b9663705599be8e331f6d2f37f152
BLAKE2b-256 checksum
How to use checksums
44fb357d565086bef2cb3a8fb57a43553a5a1c60b39f98d694551889a37c6e8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

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

Download URL python_libphash-2.0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 630.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7d8b9ea1a319d3a36e23c67a1ff8630e865ccdb19f3382073ad7a51b1920f1da
BLAKE2b-256 checksum
How to use checksums
c686298ed767959c88f2a31788a285609142768cf04eec2956bf389a135f9c3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.1.1 This release

13 release files

1.4.1

26 release files

1.4.0

26 release files

1.3.0

26 release files

1.2.0

26 release files

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