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).
41
+
Use the `Reader` to read C2PA data from the specified file.
42
+
This examines the specified media file for C2PA data and generates a 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).
46
43
47
44
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.
48
45
49
-
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.
46
+
The manifests may contain binary resources such as thumbnails which can be retrieved with `resource_to_stream` or `resource_to_file` using the associated `identifier` field values and a `uri`.
50
47
51
48
NOTE: For a comprehensive reference to the JSON manifest structure, see the [Manifest store reference](https://opensource.contentauthenticity.org/docs/manifest/manifest-ref).
52
-
53
-
### Add a signed manifest to a media file
54
-
55
-
Use the `sign_file` function to add a signed manifest to a media file.
56
-
57
49
```py
58
-
result = c2pa.sign_file("path/to/source.jpg",
59
-
"path/to/dest.jpg",
60
-
manifest_json,
61
-
sign_info,
62
-
data_dir)
63
-
```
50
+
try:
51
+
reader = c2pa.Reader("path/to/media_file.jpg")
64
52
65
-
The parameters (in order) are:
66
-
- The source (original) media file.
67
-
- The destination file that will contain a copy of the source file with the manifest data added.
68
-
-`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.
69
-
-`sign_info`, a `SignerInfo` object instance; see [Generating SignerInfo](#generating-signerinfo) below.
70
-
-`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.
53
+
# Print the JSON for a manifest.
54
+
print("manifest store:", reader.json())
71
55
72
-
### Create a SignerInfo instance
56
+
# Get the active manifest.
57
+
manifest = reader.get_active_manifest()
58
+
if manifest !=None:
73
59
74
-
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:
60
+
# get the uri to the manifest's thumbnail and write it to a file
For the list of supported signing algorithms, see [Creating and using an X.509 certificate](https://opensource.contentauthenticity.org/docs/c2patool/x_509).
72
+
```py
73
+
try:
74
+
# Define a function to sign the claim bytes
75
+
# In this case we are using a pre-defined sign_ps256 method, passing in our private cert
76
+
# Normally this cert would be kept safe in some other location
0 commit comments