Skip to main content

fast-c2pa-python

A Python library for reading C2PA metadata based on c2pa-rs

Overview

This library provides fast C2PA metadata extraction from digital assets using direct PyO3 bindings to the Rust C2PA implementation. It was created to address performance bottlenecks in existing Python C2PA libraries.

Note: This library is designed for reading C2PA metadata only. It does not support writing or creating C2PA metadata at this time.

Benchmarks

Implementation Average Read Time
c2pa-python (UniFFI) v8 ~486ms
numbers-c2pa ~17ms
fast-c2pa-python (PyO3) ~8ms
Native Rust ~7ms

Installation

pip install fast-c2pa-python

Usage

Basic Usage

from fast_c2pa_python import read_c2pa_from_file

# Read C2PA metadata from a file (with automatic MIME type detection)
metadata = read_c2pa_from_file("path/to/image.jpg")
print(metadata)

# You can also specify the MIME type explicitly if needed
metadata = read_c2pa_from_file("path/to/image.jpg", "image/jpeg")

Reading from Binary Data

from fast_c2pa_python import read_c2pa_from_bytes

# From HTTP response or other binary source
response = requests.get("https://example.com/image.jpg")
metadata = read_c2pa_from_bytes(response.content, "image/jpeg")

# Or from a file opened in binary mode
with open("path/to/image.jpg", "rb") as f:
    data = f.read()
    metadata = read_c2pa_from_bytes(data, "image/jpeg")

Example Output

{
    "title": "Image Title",
    "generator": "Adobe Photoshop",
    "thumbnail": {...},
    "assertions": [...],
    "signature_info": {
        "issuer": "Example Issuer",
        "time": "2023-05-23T10:30:15Z",
        "cert_serial_number": "1234567890"
    },
    "ingredients": [...],
    # Additional manifest data
}

Testing

The library includes API compatibility tests to ensure functionality.

Running Tests

Install test dependencies:

pip install -r tests/requirements.txt

Run API tests:

python run_tests.py --api-only

Development

This library is built using Maturin, which provides Python bindings for Rust with PyO3.

Setting Up Development Environment

# Install Maturin
pip install maturin

# Development build (debug mode)
maturin develop

# Run in release mode for better performance
maturin develop --release

Building Wheel Files

# Build wheel for the current platform
maturin build --release

Wheel files are generated in the `target/wheels/` directory and can be shared directly with users who can install them using pip:

```bash
pip install /path/to/fast_c2pa_python-x.x.x-cp3xx-cp3xx-platform.whl

License

This project is dual-licensed under both MIT and Apache 2.0 licenses to ensure compatibility with the underlying c2pa-rs library.

Attribution

This library is built upon the excellent work of the c2pa-rs library by the Content Authenticity Initiative. The c2pa-rs library provides the core C2PA implementation in Rust, and this project creates Python bindings using PyO3 for improved performance.

Developed by: Sightengine - AI-powered content moderation

Key Dependencies:

  • c2pa-rs - Core C2PA implementation
  • PyO3 - Rust bindings for Python

Special thanks to the Content Authenticity Initiative and the c2pa-rs contributors for their foundational work on C2PA standards and implementation.

Metadata

Release files for fast-c2pa-python 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fast-c2pa-python 0.1.6
File Interpreter ABI Platform Actions
fast_c2pa_python-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details for fast_c2pa_python-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl
fast_c2pa_python-0.1.6-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details for fast_c2pa_python-0.1.6-cp311-cp311-manylinux_2_34_x86_64.whl

Total release size: 13.6 MB

Release files / fast_c2pa_python-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL fast_c2pa_python-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl
Size 6.8 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
c3712ccff62fd1a7c2930ad2b1de0d16a6cd78b712dee38e4da5e87291daeb0e
BLAKE2b-256 checksum
How to use checksums
7565d6cea3bbdbd8050e291b4efbee860cb453f7a98f0e2f953a94436190c4fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 11, 2025.

Transparency log

Release files / fast_c2pa_python-0.1.6-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL fast_c2pa_python-0.1.6-cp311-cp311-manylinux_2_34_x86_64.whl
Size 6.8 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
bc74e4d84c8771a3b876bc16994b8d0dd92e69011d5b4fdac01ee7d45eb9ece0
BLAKE2b-256 checksum
How to use checksums
251c06c00274de7506cb9fb8e4170293ec60e2be94828c226b6418342017413c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 11, 2025.

Transparency log

Security for fast-c2pa-python 0.1.6

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fast_c2pa_python-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 11, 2025.

Transparency log

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