Skip to main content

jpegtrust

Embed, extract, and verify JPEG Trust provenance metadata.

jpegtrust is a Python package for working with JPEG Trust provenance metadata based on the C2PA and JUMBF standards. It lets you embed signed metadata into JPEG images, extract it back out, and verify images against configurable trust profiles.

Installation

pip install jpegtrust

Quick start

from jpegtrust import embed_image, extract_from_file, verify_image, create_profile, save_profile

# Create a trust profile
profile = create_profile(template="newsroom", name="Wire Photo Policy")
save_profile(profile, "profile.yml")

# Embed metadata into an image
embed_image("photo.jpg", "metadata.json", "signed.jpg")

# Extract metadata
metadata = extract_from_file("signed.jpg")

# Verify against the profile
report = verify_image("signed.jpg", "profile.yml")
print(f"{report.status} | {report.score} | {report.passed_checks}/{report.total_checks}")

CLI

# Profile operations
jpegtrust profile list-templates
jpegtrust profile list-checks
jpegtrust profile create --template newsroom -o profile.yml

# Embed metadata
jpegtrust embed photo.jpg metadata.json -o signed.jpg

# Extract metadata
jpegtrust extract signed.jpg
jpegtrust extract signed.jpg -o metadata.json

# Verify
jpegtrust verify signed.jpg profile.yml
jpegtrust verify signed.jpg profile.yml --format json

# Batch operations
jpegtrust batch embed ./photos metadata.json -o ./signed
jpegtrust batch extract ./signed -o ./extracted
jpegtrust batch verify ./signed profile.yml

API reference

Embedding

Function Description
embed_image(image, metadata, output) Embed metadata from a file path or dict into a JPEG
embed_metadata(image_bytes, metadata_dict) Embed metadata into raw JPEG bytes

Extraction

Function Description
extract_from_file(image) Extract and parse metadata from a JPEG file
extract_metadata(image_bytes) Extract raw JSON string from JPEG bytes

Verification

Function Description
verify(indicator, profile_yaml) Verify an indicator dict against a profile YAML string
verify_image(image_path, profile_path) Extract + verify in one call

Profiles

Function Description
create_profile(template, name, issuer) Create a profile from a predefined template
save_profile(profile, path) Save profile as YAML
load_profile(path) Load profile YAML from file
list_templates() List available templates and their checks
list_checks() List all available check definitions

Batch

Function Description
batch_embed(input_dir, metadata, output_dir) Embed metadata into all images in a directory
batch_extract(input_dir, output_dir) Extract metadata from all images
batch_verify(input_dir, profile) Verify all images against a profile

Templates

Template Checks Use case
newsroom All 9 checks Wire photos, editorial verification
insurance signature, timestamp, author, edit history, GPS, pixel hash Claims photo validation
creator signature, author, copyright, AI declaration, pixel hash Artist authenticity
ai-labelling signature, AI declaration, digital source type, AI labelling, edit history, pixel hash, data mining AI labelling
custom None (you pick) Build your own

Trust profiles

Trust profiles are multi-document YAML files that define verification rules. Each rule contains an expression evaluated against the image's Trust Indicator Set (ISO/DIS 21617-1 A.4). In that set, declaration is the Trust Declaration written when the asset was created, and manifests lists the other Trust Manifests with the active one first, so manifests[0] is the active manifest:

---
metadata:
  name: "My Profile"
  issuer: "My Organization"
  date: "2025-01-01T00:00:00Z"
  version: "1.0.0"
  language: en

---
- id: signature_check
  expression: >
    manifests[0].status.signature == "claimSignature.validated"
  report_text:
    'true':
      en: "Valid signature"
    'false':
      en: "No valid signature"

Verification report

report = verify_image("signed.jpg", "profile.yml")

report.status        # "pass" | "warning" | "fail"
report.score         # 0.0 - 1.0
report.verdict       # "trusted" | "mostly_trusted" | "profile_mismatch"
report.passed        # ["signature_chain", "pixel_hash", ...]
report.failed        # ["gps_location", ...]
report.total_checks  # 9
report.passed_checks # 7
report.c2pa          # C2PA detection info
report.to_dict()     # Full report as a dict

License

MIT

Metadata

Release files for jpegtrust 0.2.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 jpegtrust 0.2.0
File Size Uploaded Provenance Actions
jpegtrust-0.2.0.tar.gz 2.4 MB Without provenance Details for jpegtrust-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jpegtrust 0.2.0
File Interpreter ABI Platform Actions
jpegtrust-0.2.0-py3-none-any.whl Python 3 none any Details for jpegtrust-0.2.0-py3-none-any.whl

Total release size: 2.5 MB

Release files / jpegtrust-0.2.0.tar.gz

Download URL jpegtrust-0.2.0.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
8e3813e6a433ea4aec1b3153f185792c5afd52605c4a25e6688e36d02215a7b3
BLAKE2b-256 checksum
How to use checksums
28c7ddb3caecc842984b9ae90a7bc302abbe64766a0b1f70fa346f70a92ee43a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / jpegtrust-0.2.0-py3-none-any.whl

Download URL jpegtrust-0.2.0-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b9169e0b6c2289cb1d6b02e7506eb67196b8887bb10b79a203cd5c2ce8bade7
BLAKE2b-256 checksum
How to use checksums
1b070169e421701329b8d80b63799b6318aa5a8cfc83c28a16d1273642f1c1fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for jpegtrust 0.2.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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