jpegtrust Python Package
A Python library and CLI for embedding, extracting, and verifying JPEG Trust provenance metadata. Built on the JUMBF box structure.
Embed & Extract
Inject provenance metadata into JPEG images and read it back out. Works with both file paths and raw bytes.
Verify
Validate images against configurable trust profiles. Get scored reports with pass, warning, or fail status.
Profiles & Templates
Create trust profiles from built-in templates (newsroom, insurance, creator, AI labelling) or build your own.
Batch & CLI
Process entire directories of images at once. Use from Python code or the command line.
Requirements
Python ≥ 3.10
Dependencies click, pyyaml, c2pa-python
License MIT
Version 0.2.0
Installation
pip
pip install jpegtrust
Or install from source for development:
from source
git clone https://github.com/jpeg-trust/jpegtrust.git cd jpegtrust pip install -e ".[dev]"
Quick start
Here's a complete workflow: create a trust profile, embed metadata into an image, then verify it.
Python
import jpegtrust # 1. Create a trust profile from a template profile = jpegtrust.create_profile( template="newsroom", name="Wire Photo Policy", issuer="My News Agency", ) jpegtrust.save_profile(profile, "policy.yml") # 2. Embed metadata into a JPEG image jpegtrust.embed_image("photo.jpg", "metadata.json", "signed.jpg") # 3. Verify the image against the profile report = jpegtrust.verify_image("signed.jpg", "policy.yml") print(report.status) # "pass", "warning", or "fail" print(report.score) # 0.0 to 1.0 print(report.verdict) # "trusted", "mostly_trusted", or "profile_mismatch" print(report.passed) # ["signature_chain", "capture_timestamp", ...] print(report.failed) # ["gps_location", ...]
Or use the command line:
CLI
# Create a profile jpegtrust profile create --template newsroom --name "Wire Photo Policy" -o policy.yml # Embed metadata jpegtrust embed photo.jpg metadata.json -o signed.jpg # Verify jpegtrust verify signed.jpg policy.yml # Get JSON output for pipelines jpegtrust verify signed.jpg policy.yml --format json
What's in the package
Module Functions Description
jpegtrust.embed embed_image, embed_metadata Inject metadata into JPEGs
jpegtrust.extract extract_from_file, extract_metadata Read metadata from JPEGs
jpegtrust.verify verify, verify_image Validate against trust profiles
jpegtrust.profile create_profile, load_profile, save_profile, ... Create and manage trust profiles
jpegtrust.batch batch_embed, batch_extract, batch_verify Bulk operations on directories
jpegtrust.iptc IPTC_DIGITAL_SOURCE_TYPES, is_ai_generated, validate_digital_source_type, ... IPTC digital source type constants and helpers
Available templates
Templates are pre-built sets of trust checks for common use cases. Pass a template name to create_profile() to get started quickly.
Template Checks Best for
newsroom All 11 Wire photos, editorial verification
insurance 6 Claims photo validation with GPS
creator 6 Artist authenticity and rights
ai-labelling 7 AI-generated content labelling (incl. IPTC digital source type)
custom 0 Pick your own checks
How it works
jpegtrust workflow
Embed
JPEG + JSON metadata
↓
embed_image()
↓
JPEG with JUMBF data
Extract
Embedded JPEG
↓
extract_from_file()
↓
Indicator dict
Verify
JPEG + trust profile
↓
verify_image()
↓
VerificationReport