Reading manifest data
- JavaScript
 - Python
 - Node.js
 - C++
 - Rust
 
That JavaScript library is being extensively revised so the APIs used here may change in the near future.
Use c2pa.read to read manifest data from an asset; if the asset has a C2PA manifest and was processed without errors, the returned c2paReadResult contains a manifestStore object with several useful properties:
- manifests: An object containing all the asset's manifests (
Manifestobjects), keyed by UUID. - activeManifest: A pointer to the latest 
manifestin the manifest store. Effectively the "parent" manifest, this is the likely starting point when inspecting an asset's C2PA data. - validationStatus: A list of any validation errors encountered. See Validation for more information.
 
const version = '0.30.14';
const sampleImage = '<IMAGE_URL>';
import { createC2pa } from 'https://cdn.jsdelivr.net/npm/c2pa@${version}/+esm';
(async () => {
  // Initialize the c2pa-js SDK
  const c2pa = await createC2pa({
    wasmSrc:
      'https://cdn.jsdelivr.net/npm/c2pa@${version}/dist/assets/wasm/toolkit_bg.wasm',
    workerSrc:
      'https://cdn.jsdelivr.net/npm/c2pa@${version}/dist/c2pa.worker.min.js',
  });
  try {
    // Read in image and get a manifest store
    const { manifestStore } = await c2pa.read(sampleImage);
    console.log('manifestStore', manifestStore);
    // Get the active manifest
    const activeManifest = manifestStore?.activeManifest;
    console.log('activeManifest', activeManifest);
  } catch (err) {
    console.error('Error reading image:', err);
  }
})();
Use the Reader object to read manifest data from a file or stream and perform validation on the manifest store. 
Use the json() method to return a JSON manifest report; If there are validation errors, the report includes a validation_status field.
An asset file may contain many manifests in a manifest store. The most recent manifest is identified by the value of the active_manifest field in the manifests map.
# Import the C2PA Python package.
from c2pa import *
# Import standard general-purpose packages.
import os
import io
import logging
import json
try:
  # Create a reader from a file path.
  reader = c2pa.Reader.from_file("path/to/media_file.jpg")
  # Print the JSON for a manifest.
  print("manifest store:", reader.json())
except Exception as err:
    print(err)
The Node.js library is being revised. The documentation will be updated as soon as possible with the latest changes.
Use the read_file function to read C2PA data from the specified file. This function examines the specified asset file for C2PA data and returns a JSON report if it finds any; it throws exceptions on errors. If there are validation errors, the report includes a validation_status field.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <stdexcept>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include "c2pa.hpp"
#include "test_signer.hpp"
using namespace std;
namespace fs = std::filesystem;
using namespace c2pa;
auto json_store = C2pa::read_file("work/media_file.jpg", "output/data_dir")
Where:
work/media_file.jpgis the asset file to read.output/data_diris the optional path to data output directory; If provided, the function extracts any binary resources, such as thumbnails, icons, and C2PA data into that directory. These files are referenced by the identifier fields in the manifest store report.
Use the Reader struct to read manifest data from a file or stream.
Reading from a file
Use from_file to read manifest data from a file:
use std::{
    io::{Cursor, Write},
    process::{Command, Stdio},
};
use anyhow::Result;
use c2pa::{settings::load_settings_from_str, Builder, CallbackSigner, Reader};
use c2pa_crypto::raw_signature::SigningAlg;
use serde_json::json;
const TEST_IMAGE: &[u8] = include_bytes!("../tests/fixtures/CA.jpg");
const CERTS: &[u8] = include_bytes!("../tests/fixtures/certs/ed25519.pub");
const PRIVATE_KEY: &[u8] = include_bytes!("../tests/fixtures/certs/ed25519.pem");
use c2pa::Reader;
let reader = Reader::from_file("path/to/file.jpg").unwrap();
There is also an asynchronous version of this method, from_stream_async.
Reading from a stream
Use from_stream to read manifest data from a stream:
use std::{
    io::{Cursor, Write},
    process::{Command, Stdio},
};
use anyhow::Result;
use c2pa::{settings::load_settings_from_str, Builder, CallbackSigner, Reader};
use c2pa_crypto::raw_signature::SigningAlg;
use serde_json::json;
const TEST_IMAGE: &[u8] = include_bytes!("../tests/fixtures/CA.jpg");
const CERTS: &[u8] = include_bytes!("../tests/fixtures/certs/ed25519.pub");
const PRIVATE_KEY: &[u8] = include_bytes!("../tests/fixtures/certs/ed25519.pem");
let mut stream = Cursor::new(include_bytes!("../tests/fixtures/CA.jpg"));
let reader = Reader::from_stream("image/jpeg", stream).unwrap();
println!("{}", reader.json());
There is also an asynchronous version of this method, from_stream_async.