PHP code example of provemark / content-credentials
1. Go to this page and download the library: Download provemark/content-credentials library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
provemark / content-credentials example snippets
use Provemark\ContentCredentials\Core\Manifest\ManifestBuilder;
use Provemark\ContentCredentials\Core\Manifest\MediaType;
use Provemark\ContentCredentials\Core\Signing\Asset;
use Provemark\ContentCredentials\Laravel\ContentCredentials;
$manifest = ManifestBuilder::forAiGenerated(MediaType::Png)
->withSoftwareAgent('ACME GenAI Image Model', '3.1.0')
->build();
$signed = ContentCredentials::sign(
new Asset(file_get_contents('image.png'), MediaType::Png),
$manifest,
);
file_put_contents('signed.png', $signed->bytes);
$report = ContentCredentials::read(new Asset($signed->bytes, MediaType::Png));
$report->isVerifiedAiGenerated(); // true — marked AND the signature checked out
$report->signer()?->issuer; // "C2PA Test Signing Cert"
use Provemark\ContentCredentials\Core\Manifest\MediaType;
use Provemark\ContentCredentials\Core\Reading\ExtC2paReader;
use Provemark\ContentCredentials\Core\Signing\Asset;
$report = (new ExtC2paReader)->read(
new Asset(file_get_contents('photo.jpg'), MediaType::Jpeg),
);
$report->hasManifest(); // false when the file carries no credential
$report->isAiGenerated(); // marked as trainedAlgorithmicMedia
$report->isSignatureValid(); // the signature checks out
$report->softwareAgents(); // which system says it made this
bash
pie install ericmann/ext-c2pa # https://github.com/php/pie
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.