c2pa 0.1.0

Rust SDK for C2PA (Coalition for Content Provenance and Authenticity) implementors
Documentation

This library supports reading, creating and embedding C2PA data with JPEG and PNG images.

Example: Reading and displaying a manifest as JSON

# use c2pa::Result;
use c2pa::ManifestStore;
# fn main() -> Result<()> {
let manifest_store = ManifestStore::from_file("tests/fixtures/C.jpg")?;
println!("{}", manifest_store);
# Ok(())
# }

Example: Adding a manifest to a file

# use c2pa::Result;
use c2pa::{
Manifest,
openssl::temp_signer::get_signer,
assertions::User
};
use std::path::PathBuf;
use tempfile::tempdir;
# fn main() -> Result<()> {
let mut manifest = Manifest::new("my_app".to_owned());
manifest.add_assertion(&User::new("org.contentauth.mylabel",r#"{"my_tag":"Anything I want"}"#))?;
let source = PathBuf::from("tests/fixtures/C.jpg");
let dir = tempdir()?;
let dest = dir.path().join("test_file.jpg");
let (signer, _) = get_signer(&dir.path());
manifest.embed(&source, &dest, &signer)?;
# Ok(())
# }