You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function examines the specified media file for C2PA data and generates a JSON report of any data it finds. If there are validation errors, the report includes a `validation_status` field. For a summary of supported media types, see [Supported file formats](#supported-file-formats).
A media 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.
23
36
24
-
This will examine any supported media file for c2pa data and generate
25
-
a JSON report of any data it finds. The report will include a validation_status field if any validation errors were found.
37
+
If the optional `data_dir` is 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.
26
38
27
-
A media file may contain many manifests in a manifest store. The most recent manifest can be accessed by looking up the active_manifest field value in the manifests map.
39
+
NOTE: For a comprehensive reference to the JSON manifest structure, see the [CAI manifest store reference](https://contentauth.github.io/json-manifest-reference/manifest-reference).
28
40
29
-
If the optional data_dir is provided, any binary resources, such as thumbnails, icons and c2pa_data will be extracted into that directory.
30
-
These files will be referenced by the identifier fields in the manifest store report.
41
+
### Add a signed manifest to a media file
31
42
43
+
Use the `add_manifest_to_file_json` function to add a signed manifest to a media file.
32
44
33
-
### Adding a Signed Manifest to a media file
34
-
The source is the media file which should receive new c2pa data.
35
-
The destination will have a copy of the source with the data added.
36
-
The manifest Json is a a JSON formatted string containing the data you want to add.
37
-
(see: [Generating SignerInfo](#generating-signerinfo) for how to construct SignerInfo)
38
-
The optional data_dir allows you to load resource files referenced from manifest_json identifiers.
39
-
When building your manifest, any files referenced by identifier fields will be loaded relative to this path.
40
-
This allows you to load thumbnails, icons and manifest data for ingredients
45
+
```py
46
+
result = c2pa.add_manifest_to_file_json("path/to/source.jpg",
- The destination file that will contain a copy of the source file with the manifest data added.
56
+
-`manifest_json`, a JSON-formatted string containing the manifest data you want to add; see [Creating a manifest JSON definition file](#creating-a-manifest-json-definition-file) below.
57
+
-`sign_info`, a `SignerInfo` object instance; see [Generating SignerInfo](#generating-signerinfo) below.
58
+
-`data_dir` optionally specifies a directory path from which to load resource files referenced in the manifest JSON identifier fields; for example, thumbnails, icons, and manifest data for ingredients.
43
59
44
60
### Generating SignerInfo
45
61
46
-
Set up the signer info from pem and key files.
62
+
A `SignerInfo` object contains information about a signature. To create an instance of `SignerInfo`, first set up the signer information from the public and private key `.pem` files as follows:
For the list of supported signing algorithms, see [Creating and using an X.509 certificate](https://opensource.contentauthenticity.org/docs/c2patool/x_509).
56
76
57
-
### Creating a Manifest Json Definition File
77
+
### Creating a manifest JSON definition file
58
78
59
-
The manifest json string defines the c2pa to add to the file.
79
+
The manifest JSON string defines the C2PA manifest to add to the file.
60
80
61
-
```
81
+
```py
62
82
manifest_json = json.dumps({
63
83
"claim_generator": "python_test/0.1",
64
84
"assertions": [
@@ -75,28 +95,35 @@ manifest_json = json.dumps({
75
95
}
76
96
]
77
97
})
78
-
```
79
-
## Development
80
-
81
-
It is best to set up a virtual environment for development and testing
0 commit comments