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

Built distributions (wheels)

Table of built distributions (wheels) for python-libphash 2.0.1.0
File
python_libphash-2.0.1.0-cp315-cp315t-win_amd64.whl CPython 3.15 CPython 3.15 free-threading Windows x86-64 Details
python_libphash-2.0.1.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.1.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.1.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.1.0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details
python_libphash-2.0.1.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
python_libphash-2.0.1.0-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.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.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
python_libphash-2.0.1.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.1.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
python_libphash-2.0.1.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.1.0.tar.gz

Download URL python_libphash-2.0.1.0.tar.gz
Size 10.7 MB
Tags Source
SHA-256 checksum
How to use checksums
79710982d8b88d6a36c87d72edc480ef29c303139933c30fe51ee3b4d975d670
BLAKE2b-256 checksum
How to use checksums
13812442df42126f5e501fbc9ecf9ae0ddcbb03ac28b194e7d07857fc3c78df1
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.0-cp315-cp315t-win_amd64.whl

Download URL python_libphash-2.0.1.0-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
59de8975a8b64ef3619eb0bd9257c9409de5a9797019f48b8be01ebef90145b1
BLAKE2b-256 checksum
How to use checksums
8a35def286a89753f788a443a94d65a1705e14dd3ecdd6feef1998c30f2025e6
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.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_libphash-2.0.1.0-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 912.8 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
f54a80864cdba8a888f385875b404058bb430325bd66796bff735eec74ce2e97
BLAKE2b-256 checksum
How to use checksums
002e8a0d5c45df457e12ff3dc5fa8f593a96b9320d5a601b321e50cc5b12be9d
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.0-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL python_libphash-2.0.1.0-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
c6d5994e5d0545edb02d81957b2bdf9cd99e6166ee56e8c51ddf94a8b0458db0
BLAKE2b-256 checksum
How to use checksums
634f00d419cd94495054d2d11449d451a75c2cd0e823d30add15238e055cd031
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.0-cp315-cp315t-macosx_11_0_arm64.whl

Download URL python_libphash-2.0.1.0-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
1ef74977dcd4171a2c787e57d5ca7140c6661fa1b48f90f96f74a072aa8c92eb
BLAKE2b-256 checksum
How to use checksums
09d6a1db9622e560b1f442e182e9d3cca9499dd93df4a63442bb665947cc5368
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.0-cp314-cp314t-win_amd64.whl

Download URL python_libphash-2.0.1.0-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
e354565b3bcec2d6d1bf165403a371db887a1b0c321a06c78bf24cee70030d28
BLAKE2b-256 checksum
How to use checksums
af5f00b4511ab13704838c57f7da061e28b3e42c89353b1b1d4220b27797ac99
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.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_libphash-2.0.1.0-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
749a2ee83e1db89eb5ae703a42390362598bda2f9e07bf4cfe2d0d4e55e1faff
BLAKE2b-256 checksum
How to use checksums
4930b3c62e96d47fafbf377ae8437d4da004de4ae9adb30e6a85aae96bc87d07
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.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL python_libphash-2.0.1.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
603ce87c39609f8dbceab79137efc75b9649457ffaec9e2981d4619175fb8717
BLAKE2b-256 checksum
How to use checksums
8f3c2adccc5eafd17504ef28ef9b3bf6f605536096a08e6fcefb2c2516614199
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.0-cp314-cp314t-macosx_11_0_arm64.whl

Download URL python_libphash-2.0.1.0-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
1d7f42b3333eb41889eb121b088191900ddd1330ae9407a50cac4f881ddff49d
BLAKE2b-256 checksum
How to use checksums
8a86187186ff6e813a6494d0502d5fb93efe347110af875d9e04296b951bc795
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.0-cp310-abi3-win_amd64.whl

Download URL python_libphash-2.0.1.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
9527ab4d893b33f1023f316673ec474e674a29d77b71c51352261607ec0c1b0c
BLAKE2b-256 checksum
How to use checksums
732f07513d66124db5fdf78a2a26d9409f0a3f9ad4182c4fe7ce62c079c292a8
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.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL python_libphash-2.0.1.0-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
38fe13515d87b56eb5f020c90780ad9d79a4c42b3bf2443bac161d8950d213e2
BLAKE2b-256 checksum
How to use checksums
740c6db3a92494ff7a9ae218794f59b71d7b2a00388ee2fb796b8b2dc1d3f420
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.0-cp310-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL python_libphash-2.0.1.0-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
d8d7c83a5b653b6e9e2dc68aebf3bec8e4edb318b621c73d2fe99a37ece9b3f5
BLAKE2b-256 checksum
How to use checksums
9d3501683841adc493f34bcf14edd4abada10eb6630b8f91d458e2bb710a807e
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.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL python_libphash-2.0.1.0-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
f30ccbb08befefd018e74fce9a6d0f55c9c56770cab1c5c492ea10ea9dff0b1d
BLAKE2b-256 checksum
How to use checksums
d7c8f0a9ae95f8ec0487b7627640b03ef1da645cb37ae523307b02e201eb7e76
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.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