Search by

bencevans / image-data-hash

bencevans

Native JPEG image data hashing compatible with ExifTool

Package info

github.com/bencevans/image-data-hash

Language:Python

pkg:composer/bencevans/image-data-hash

Fund package maintenance!

bencevans

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-09-07 17:25 UTC

This package is auto-updated.

Last update: 2026-09-07 17:56:45 UTC


README

Language native implementations of ExifTool's ImageDataHash for JavaScript, Python, Rust, R and PHP. Following ExifTool's default behaviour the hashing algorithm is MD5 with the option for SHA-256 or SHA-512.

The initial implementations have been generated by GPT-6 Astra.

Language Package Documentation
TypeScript / JavaScript (Node.js) image-data-hash JavaScript README
Python image_data_hash Python README
Rust image_data_hash Rust README
R imageDataHash R README
PHP / Composer bencevans/image-data-hash PHP README

Each implementation includes installation instructions, API examples, and development commands. See release checks for the publishing workflow.

Compatibility and scope

Currently supports JPEG only. Hashing follows ExifTool's scan-chunk selection, including its behavior for progressive JPEGs, byte stuffing, restart markers, fill bytes and intervening length-bearing segments. See the byte rules.

EXIF, IPTC, XMP, ICC profiles and tables before the scans are excluded. For ordinary baseline JPEGs the hash covers SOS through the byte before EOI. It is not a decoded-pixel or perceptual hash. MD5 is provided for compatibility; select SHA-256 or SHA-512 when collision resistance matters.

JavaScript, Python, Rust and PHP offer streaming APIs. R reads one image into memory. Caller-owned Python/PHP streams stay open; JavaScript closes its input iterator when hashing finishes. Parsers may read ahead, so streams are not positioned for reading concatenated JPEGs after a call.

Tests

Install ExifTool and cjpeg (for example, Ubuntu packages libimage-exiftool-perl libjpeg-turbo-progs), then run:

python3 fixtures/generate.py fixtures/generated

The destination must be empty. All five suites require the shared manifest. CI generates it once and distributes the identical artifact to every language. The manifest contains ExifTool's MD5, SHA-256 and SHA-512 results for 41 files: two camera originals, 30 metadata variants, three encoder variants, and six structural edge cases. Test commands are in each implementation's README. See fixture details.