Skip to main content

image-bridge-toolkit logo

image-bridge-toolkit

PyPI version License: MIT License: CC BY-NC-ND 4.0

image-bridge-toolkit provides cache-backed perceptual image fingerprinting and cross-dataset bridge matching designed to handle large scale (50,000+ image) libraries. It finds identical or highly similar images across disparate folders while remaining resilient to scale shifts, aspect ratio changes, heavy compression, and intrusive watermarks.


Key Features

  • Per-Directory JSON Caching: Generates and maintains lightweight image_cache.json files within each directory, keyed by filename and modification time (mtime).
  • Scale-Invariant Waveform Approximations: Uses 16-float 1D Discrete Cosine Transform (DCT) grayscale histogram vectors to ignore local watermark text spikes and compression artifacts.
  • 5-Tier Matching Funnel:
    1. Tier 1 (Bitwise pHash Luma + Color): Generous 64-bit Hamming filtering to eliminate obvious non-matches.
    2. Tier 2 (Histogram Waveform): Euclidean distance on 16 low-frequency DCT coefficients to filter lighting distribution changes.
    3. Tier 3 (LAB Perceptual Metrics): Vector distance across lab_value, lab_hue, lab_chroma, and lab_warmth.
    4. Tier 4 (Spatial Layout Tie-Breaker): 16-point color spatial coordinates down-weighting image outer margins where signatures and borders reside.
    5. Tier 5 (Optional SSIM Direct Comparison): Full structural similarity pixel comparison on top candidate matches.
  • Resumable & High Performance: Output streams as .jsonl objects, allowing runs over huge original sets to resume instantly without re-processing.
  • Zero-Dependency Fallback: Runs with OpenCV if available for acceleration, or falls back to pure NumPy + Pillow.

Installation

Install via PyPI:

# Minimal installation (NumPy + Pillow)
pip install image-bridge-toolkit

# Recommended installation (includes OpenCV acceleration & progress bars)
pip install "image-bridge-toolkit[all]"

For development:

git clone [https://github.com/akingdom/image_bridge_toolkit.git](https://github.com/akingdom/image_bridge_toolkit.git)
cd image_bridge_toolkit
pip install -e ".[all]"

Usage

1. Build or Update Metadata Caches (imgcache-build)

Walks a root directory, scanning all subdirectories (skipping any directory containing .ignore_subdir), and generates or updates image_cache.json.

# Build cache for a query dataset (e.g., 1,000 watermarked images)
imgcache-build /path/to/thumbnails_set

# Build cache for a target dataset (e.g., 50,000 original images)
imgcache-build /path/to/originals_set

2. Match Datasets (imgmatch-bridge)

Matches images from the query dataset against the target library, generating a bridge mapping file with confidence scores and top candidate lists.

imgmatch-bridge /path/to/thumbnails_set /path/to/originals_set \
    -o bridge_map.jsonl \
    --max-hamming 16 \
    --candidate-threshold 0.03 \
    --direct-compare

Command-Line Options

Flag Default Description
-o, --output bridge_map.jsonl File path for output streaming results.
--max-hamming 16 Maximum allowed Tier 1 pHash Hamming distance threshold.
--candidate-threshold 0.03 Percentage band (e.g., 3%) to include close secondary matches.
--direct-compare False Performs Tier 5 pixel-level SSIM re-ranking on candidates.

Cache Integrity & Updating

  • mtime Matching: A cached entry is preserved as long as the file's modification time matches the record in image_cache.json.
  • Partial Recomputation: If an existing cache entry is missing a newly added metric type (e.g., hist_waveform), only the missing calculation is executed; existing valid metrics are preserved.
  • Corrupt Cache Handling: Invalid or unparseable JSON files are automatically caught and rebuilt without interrupting directory traversal.
  • Subdirectory Exclusion: Placing a .ignore_subdir marker inside any directory causes the builder and matcher to ignore that folder and all nested subdirectories.

License & Copyright

Metadata

Release files for image-bridge-toolkit 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 image-bridge-toolkit 0.1.1
File Size Uploaded Provenance
image_bridge_toolkit-0.1.1.tar.gz 19.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for image-bridge-toolkit 0.1.1
File Interpreter ABI Platform
image_bridge_toolkit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.8 kB

Release files / image_bridge_toolkit-0.1.1.tar.gz

Download URL image_bridge_toolkit-0.1.1.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8133758920e6db75d4b5b0729d3bf8e0d71211cf7bb5cd737314e2537048deca
BLAKE2b-256 checksum
How to use checksums
6463e80f5b5df2d8a0fc2fa4640b3928bea4088f0624a986033d8fe138f9a494
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release files / image_bridge_toolkit-0.1.1-py3-none-any.whl

Download URL image_bridge_toolkit-0.1.1-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63261da56bc3a293bc92168766028231734bd455fc7c3bfcf66a1256bd14fb14
BLAKE2b-256 checksum
How to use checksums
696ec28b3044e234c5ed87e8b8ef9b03b01673879ddecb76f7c0a7070ce9df27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Security for image-bridge-toolkit 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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