Skip to main content

image_data_hash for Python

Native JPEG ImageDataHash matching ExifTool. Python 3.10+; no runtime dependencies. Distribution and import name: image_data_hash.

Installation

python3 -m pip install image_data_hash

Usage

from image_data_hash import image_data_hash, image_data_hash_bytes, image_data_hash_stream

digest = image_data_hash("photo.jpg")  # MD5 by default
digest = image_data_hash("photo.jpg", algorithm="sha256")
digest = image_data_hash("photo.jpg", algorithm="sha512")

with open("photo.jpg", "rb") as source:
    digest = image_data_hash_stream(source, algorithm="sha256")

digest = image_data_hash_bytes(jpeg_bytes, algorithm="sha256")

Names such as MD5, SHA-256 and SHA-512 are accepted. Returns lowercase hexadecimal. Path calls close their files; stream calls leave caller-owned streams open. Streams must provide blocking binary reads. Hashing uses bounded working memory; the buffer helper retains the input in memory. Invalid/truncated JPEGs raise ValueError; file errors propagate.

Tests

Generate the shared fixtures first, then:

cd image-data-hash-py
uv sync --locked
uv run black --check src tests
uv run pytest -q

Tests compare both file and bytes APIs against ExifTool for all three algorithms, including one-byte reads. See compatibility rules.

Project

Repository: bencevans/image-data-hash. Maintainer: Ben Evans. Licensed under MIT.

Metadata

Release files for image-data-hash 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 image-data-hash 0.1.0
File Size Uploaded
image_data_hash-0.1.0.tar.gz 92.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for image-data-hash 0.1.0
File Interpreter ABI Platform
image_data_hash-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 97.9 kB

Release files / image_data_hash-0.1.0.tar.gz

Download URL image_data_hash-0.1.0.tar.gz
Size 92.4 kB
Tags Source
SHA-256 checksum
How to use checksums
edde32889b4312f22f5774fe32c04edc4a7bec4112c1afed9ae2a2968fe46b6f
BLAKE2b-256 checksum
How to use checksums
449dc52dcab49346dec554ac089952acc564588dd2e7e90549a4ce4690d45471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / image_data_hash-0.1.0-py3-none-any.whl

Download URL image_data_hash-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f74245109e9a8f4498f60d7731c18eecfb5c3d939876bfbd5e108e25f2464148
BLAKE2b-256 checksum
How to use checksums
51499ca3033491397cd7c76f635b9173da0caa4d6535c99dc4bde9084e55e848
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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