Skip to main content

image-analyser

PyPI Python License: MIT

Static image analysis (CLI + FastAPI) for the analyser family.

Given a single image file, image-analyser returns:

  • Format — JPEG / PNG / WebP / AVIF / HEIC / GIF / TIFF / BMP, MIME type, resolution, megapixels, aspect class, colour mode, bit depth, alpha, file size.
  • Hashes — SHA-256 of bytes, perceptual pHash and dHash for dedup.
  • Metadata — EXIF (camera, lens, ISO, GPS, timestamp), IPTC, XMP, ICC profile, C2PA Content Credentials.
  • Quality — blur (Laplacian variance), exposure (under / over / clipping), brightness, contrast, noise, JPEG-quality estimate.
  • Colour — k-means dominant palette + average colour.
  • Barcodes / QR codes — via pyzbar.
  • Animation — frame count + duration for GIF / WebP.
  • Object detection (opt-in [ml]) — DETR by default; configurable HuggingFace pipeline.
  • Caption / textual description (opt-in [ml] or [api]) — local BLIP, or one of Anthropic / OpenAI / Google / OpenRouter.
  • OCR (opt-in [ocr]) — Tesseract or EasyOCR.

Anything that can't run in the current install lands in result.skipped[] with a stable reason. Anything that raises lands in result.failed[]. The HTTP response stays 200.

Install

pip install image-analyser              # Tier 1 only
pip install image-analyser[ml]          # + DETR object detection + local BLIP captioning
pip install image-analyser[ocr]         # + Tesseract / EasyOCR
pip install image-analyser[api]         # + API captioning (no torch needed)
pip install image-analyser[all]         # everything

System dependencies:

  • libzbar0 (for barcode/QR detection): brew install zbar / apt install libzbar0
  • libmagic (for MIME detection): brew install libmagic / apt install libmagic1
  • tesseract (only if [ocr] extra used and tesseract is the engine): brew install tesseract / apt install tesseract-ocr

CLI

image-analyser photo.jpg                          # pretty JSON
image-analyser photo.jpg --json                   # compact JSON
image-analyser photo.jpg --skip caption,ocr       # opt out
image-analyser photo.jpg --only metadata,quality  # opt in
image-analyser photo.jpg --caption-backend local  # force local BLIP
image-analyser serve                              # FastAPI on :8006
image-analyser serve --port 9000

Legal --skip / --only values: metadata, quality, colour, hashing, barcode, objects, caption, ocr.

Exit codes: 0 on success (even with failed[]), 2 on bad input, 1 on internal error.

HTTP API

# Multipart upload
curl -F file=@photo.jpg http://127.0.0.1:8006/analyse

# JSON with absolute path
curl -X POST -H "Content-Type: application/json" \
  -d '{"path":"/abs/path/photo.jpg","skip":["caption"]}' \
  http://127.0.0.1:8006/analyse

# Health check
curl http://127.0.0.1:8006/health
# {"status": "ok", "version": "0.1.0"}

Python library

from image_analyser import ImageAnalyser

result = ImageAnalyser().analyse("photo.jpg")
print(result.metadata.exif.camera if result.metadata.exif else "no EXIF")
print(result.quality.blur_score, result.colour.dominant)
for s in result.skipped:
    print("skipped", s.name, "—", s.reason)

Configuration

All env vars use the IMAGE_ANALYSER_ prefix.

Env var Default Purpose
IMAGE_ANALYSER_PORT 8006 FastAPI port
IMAGE_ANALYSER_HOST 127.0.0.1 bind address
IMAGE_ANALYSER_MODE production production / development
IMAGE_ANALYSER_ALLOWED_ORIGINS * CORS allow-list (comma-separated)
IMAGE_ANALYSER_CAPTION_BACKEND auto auto / local / api / none
IMAGE_ANALYSER_CAPTION_PROVIDER anthropic anthropic / openai / google / openrouter
IMAGE_ANALYSER_CAPTION_MODEL provider-default model id override
IMAGE_ANALYSER_LOCAL_CAPTION_MODEL Salesforce/blip-image-captioning-base HuggingFace BLIP model id
IMAGE_ANALYSER_OCR_ENGINE auto auto / tesseract / easyocr / none
IMAGE_ANALYSER_OBJECT_DETECTION_MODEL facebook/detr-resnet-50 HuggingFace pipeline model
IMAGE_ANALYSER_OBJECT_DETECTION_THRESHOLD 0.5 detection-confidence cutoff
IMAGE_ANALYSER_DEVICE auto auto / cpu / cuda / mps
IMAGE_ANALYSER_MAX_UPLOAD_MB 50 reject larger uploads

API keys: standard provider env vars (ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, OPENROUTER_API_KEY).

Development

git clone https://github.com/michael-borck/image-analyser
cd image-analyser
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,all]"
python tests/fixtures/make_fixtures.py
pytest                  # fast tests
pytest -m slow          # opt-in ML / engine tests
ruff check .
mypy src

The analyser family

Tool PyPI Port Role
auto-analyser router (file → specialist)
bundle-analyser 8008 folder / zip walker
code-analyser 8004 source code analysis
document-analyser 8000 document analysis
git-analyser 8007 git repo analysis
image-analyser 8006 static image analysis (this repo)
records-analyser 8003 structured-records analysis
speech-analyser 8001 audio transcription / speech analysis
video-analyser 8002 video analysis
wordpress-analyser 8005 WordPress export analysis

Licence

MIT © Michael Borck.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image_analyser-0.6.0.tar.gz (283.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

image_analyser-0.6.0-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

Details for the file image_analyser-0.6.0.tar.gz.

File metadata

  • Download URL: image_analyser-0.6.0.tar.gz
  • Upload date:
  • Size: 283.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for image_analyser-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9f909270015570efb13cb8fb985af3a6d0d44845ec24c94c839eaf6f944377bb
MD5 747780b7cc2cf8a5599b4681dbe59d04
BLAKE2b-256 dc6498138942ee4fc4593047c5baec5f5548287968f111e1e602bb06a468115a

See more details on using hashes here.

File details

Details for the file image_analyser-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: image_analyser-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 30.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for image_analyser-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f6923649742d2b9eeeb01997d3e54718c0d9bbd75c19842926b6557a575f58d
MD5 053f7dd8aa3699543d96347ec079ada1
BLAKE2b-256 96f56be850ce93a072f5571897624f077467c46267c1d6e4bc8dac0bd094bc7f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page