PyC2PA is Python implementation of C2PA (Coalition for Content Provenance and Authenticity) addressing the prevalence of misleading information online through the development of technical standards for certifying the source and history (or provenance) of media content. The latest tool can be checked in C2PA tool (Command Line Interface).
-
Download the testing photo: meimei-fried-chicken-cai-cai-cai.jpg
-
Go to the CAI beta verification website and upload the photo.
-
You should see the C2PA information (3 injections) like this:
$ sudo apt install swig
$ python3 -m pip install c2pa
In command line run:
$ c2pa [-h] [-a ASSERTION] [--provider PROVIDER] [--recorder RECORDER] [-k KEY] [-c CERT] [-i INJECT] [-d]
Files used in the following examples are provided in example.zip
$ unzip example.zip
$ cd example
Generate private key and certificate.
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
Generate thumbnail image.
$ convert -resize 1024x768 meimei-fried-chicken.jpg c2pa.thumbnail.claim.jpeg.jpg
Generate meimei-fried-chicken-cai.jpg containing single C2PA injection.
$ c2pa \
-a stds.schema-org.CreativeWork.json \
-a c2pa.thumbnail.claim.jpeg.jpg \
-a starling.integrity.json \
--provider "numbersprotocol" \
--recorder "Starling Capture using Numbers Protocol" \
-k key.pem \
-c cert.pem \
-i meimei-fried-chicken.jpg
Generate meimei-fried-chicken-cai-cai.jpg containing 2 C2PA injections.
$ c2pa \
-a stds.schema-org.CreativeWork.json \
-a c2pa.thumbnail.claim.jpeg.jpg \
-a starling.integrity.json \
--provider "numbersprotocol" \
--recorder "Starling Capture using Numbers Protocol" \
-k key.pem \
-c cert.pem \
-i meimei-fried-chicken-cai.jpg
In pyc2pa/utils/
, there are two examples showing how to do single injection and multiple injection programmatically.
# Prepare testing input JPEG photo and its thumbnail.
# Assuming that testing input JPEG is ~/meimei-fried-chicken.jpg
$ cd pyc2pa/utils/
$ cp ~/meimei-fried-chicken.jpg .
$ convert -resize 50% meimei-fried-chicken.jpg meimei-fried-chicken-thumbnail.jpg
# Run single injection example
# (download meimei-fried-chicken-cai.jpg from IPFS)
# output: meimei-fried-chicken-cai.jpg
$ python3 c2pa_hello_world.py
# Run multiple injection example
# output: meimei-fried-chicken-cai-cai-cai.jpg
$ python3 c2pa_multiple_injection.py meimei-fried-chicken.jpg
- Currently, the
main
branch is based on C2PA spec draft v0.7 (compatible with the latest C2PA spec draft). - The
feature-support-c2pa-photo
branch follows the latest C2PA spec implementation. pyc2pa/utils/
contains examples of single injection and multiple injection.pyc2pa/utils/digital-signature/
contains detailed documents and example codes how to create and verify a C2PA signature.