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
Copy file name to clipboardExpand all lines: docs/usage.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ For complete working examples, see the [examples folder](https://github.com/cont
9
9
Import the objects needed from the API:
10
10
11
11
```py
12
-
from c2pa import Builder, Reader, Signer, C2paSignerInfo, C2paSigningAlg
12
+
from c2pa import Builder, Reader, Signer, C2paSigningAlg, C2paSignerInfo
13
13
```
14
14
15
15
If you want to use per-instance configuration with `Context` and `Settings`:
@@ -46,11 +46,13 @@ manifest_json = json.dumps({
46
46
})
47
47
```
48
48
49
-
## File-based operations
49
+
## File-based operation
50
50
51
51
### Read and validate C2PA data
52
52
53
-
Use the `Reader` to read C2PA data from a file. The Reader examines the 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.
53
+
Use the `Reader` to read C2PA data from the specified asset file.
54
+
55
+
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.
54
56
55
57
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. The manifests may contain binary resources such as thumbnails which can be retrieved with `resource_to_stream` using the associated `identifier` field values and a `uri`.
56
58
@@ -60,16 +62,16 @@ NOTE: For a comprehensive reference to the JSON manifest structure, see the [Man
# Get the uri to the manifest's thumbnail and write it to a file
74
+
# Get the uri to the manifest's thumbnail and write it to a file.
73
75
uri = active_manifest["thumbnail"]["identifier"]
74
76
withopen("thumbnail.jpg", "wb") as f:
75
77
reader.resource_to_stream(uri, f)
@@ -99,7 +101,7 @@ except Exception as err:
99
101
100
102
### Add a signed manifest
101
103
102
-
**WARNING**: These examples access the private key and security certificate directly from the local file system. This is fine during development, but doing so in production may be insecure. Instead use a Key Management Service (KMS) or a hardware security module (HSM) to access the certificate and key; for example as shown in the [C2PA Python Example](https://github.com/contentauth/c2pa-python-example).
104
+
**WARNING**: This example accesses the private key and security certificate directly from the local file system. This is fine during development, but doing so in production may be insecure. Instead use a Key Management Service (KMS) or a hardware security module (HSM) to access the certificate and key; for example as show in the [C2PA Python Example](https://github.com/contentauth/c2pa-python-example).
103
105
104
106
#### Signing without Context
105
107
@@ -120,7 +122,7 @@ try:
120
122
ta_url=b"http://timestamp.digicert.com"
121
123
)
122
124
123
-
# Create signer from the signer info
125
+
# Create signer using the defined SignerInfo
124
126
signer = Signer.from_info(signer_info)
125
127
126
128
# Create builder with manifest and add ingredients
@@ -133,7 +135,7 @@ try:
133
135
withopen("path/to/source.jpg", "rb") as source, open("path/to/output.jpg", "w+b") as dest:
134
136
builder.sign(signer, "image/jpeg", source, dest)
135
137
136
-
# Verify the signed file
138
+
# Verify the signed file by reading data from the signed output file
Instead of working with files, you can read, validate, and add a signed manifest to streamed data.
388
+
Instead of working with files, you can read, validate, and add a signed manifest to streamed data. This example is similar to what the file-based example does.
0 commit comments