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.2.*" 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.2.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.2.0
File Size Uploaded
python_libphash-2.0.2.0.tar.gz 10.7 MB Details

Built distributions (wheels)

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

Download URL python_libphash-2.0.2.0.tar.gz
Size 10.7 MB
Tags Source
SHA-256 checksum
How to use checksums
f3a7572b5bdc0d1fe6b25e3721411c00985ac76fe0f53a5c411e5d75ebd59a12
BLAKE2b-256 checksum
How to use checksums
4f23373b959d657c370184c0ce38146addcb83cefb583681d9732a5c07526cc6
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp315-cp315t-win_amd64.whl
Size 533.8 kB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
ff10f8edc9a03a7a02c9df0789f68aceed1f09717e74bde51e6510026503f62d
BLAKE2b-256 checksum
How to use checksums
0cd5a3c141bb21b1d11d02096ee210292b13c8aec8b377cea6c3365ea8c84cc4
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 913.0 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
9a5cfccabf1fc0634cbed828b3e85ae35965d0623722882c39815f8b53fda691
BLAKE2b-256 checksum
How to use checksums
ad078ecb96cdb6ac1acd7b2af24111e58dd0f7280b1a877357e272d535f2116b
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 837.6 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
ee3375066d39a3ba406f9b160682a8e0cd4d9b386a14af33f8ca59713d2d3091
BLAKE2b-256 checksum
How to use checksums
97f8295b57540981032a31fcd56d504eea986fdba610df35221f70efb42869c5
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp315-cp315t-macosx_11_0_arm64.whl
Size 630.6 kB
Tags CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
31e7aad580dad4a973d05c258f621ada5066bf210207d4b6a858553e7b3b63a5
BLAKE2b-256 checksum
How to use checksums
418007a99093b47bfdf13f698fcdc317e0c6d2fa629cbc782929df313edbe841
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp314-cp314t-win_amd64.whl
Size 533.9 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
f27bc416b6bb962f6996442c901629616cca347c870cfb89e43b499919eec8bb
BLAKE2b-256 checksum
How to use checksums
30426540fbf0d691a499f6438228d10d24ee0f9503df0393448fed19b75adea0
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 918.1 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
d63b85050417c8694f134c1db539e57b8c0f43fea911bb2089d23c738164f564
BLAKE2b-256 checksum
How to use checksums
5279b212fe6af1c1b5385b54d7635fdfb48d4a6176ef4fe7fca0bd82cdad012c
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-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
7c060b8f701700c25da8686e548ac59402d2e7ae806ab4c2edf002661693d338
BLAKE2b-256 checksum
How to use checksums
9da9ef888cd2a804c7d2d188ffa7d4dcd854880d848f0ea24cfb812e97d9ad0c
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp314-cp314t-macosx_11_0_arm64.whl
Size 630.7 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2abc76065091e3a523cf64f33e7af07ca53034977be4bb29df6e9c66bd853909
BLAKE2b-256 checksum
How to use checksums
38f670b69ab297ac426f99fde96ced52def8c04d9d06812259fafc15af02b920
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp310-abi3-win_amd64.whl
Size 517.3 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
063c98069b44369a0ac5ba7f893b32f451fdc99237db4f5ba77a1ae4386f77e5
BLAKE2b-256 checksum
How to use checksums
2d9096800959f2557a3bfccb0dc975804fce3102cebdd4769184275cfbca8f16
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 912.3 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
73bf8861913dfda15005c3cb12f17680f48e63273fd38d0fbf6d2244fbe7c586
BLAKE2b-256 checksum
How to use checksums
da0bb20b9e2a90a6f5519d17b78fd65797a8d527f674642797d1e7536c5b37f9
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 837.0 kB
Tags CPython 3.10 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
34d54e838030ffb0b390e857c9bfdd978336bfe319edfe81bbc58c6519c3d2b7
BLAKE2b-256 checksum
How to use checksums
3d7dea165912caabb6e34efaba5cef5ac2d6ebef3d718cdc224b9fe685dca3d7
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 15, 2026.

Transparency log

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

Download URL python_libphash-2.0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 630.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
62eacd784e476ec87ce4a67aa5219ed24b04a357140a43c587cea5bd789b66a9
BLAKE2b-256 checksum
How to use checksums
1e288bdfac9ab527be3126a9e756983ed216a2b5f391298575513e64ef6f8aa9
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 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.2.0 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