Skip to content

Commit 79228a2

Browse files
authored
Update manifest-tasks.mdx
Add Python
1 parent b12cdf9 commit 79228a2

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

docs/manifest/manifest-tasks.mdx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,37 @@ import TabItem from '@theme/TabItem';
1515
</TabItem>
1616

1717
<TabItem value="python" label="Python">
18-
This is how to read a manifest using Python.
18+
19+
Use the `Reader` object to read manifest data from a file or stream and perform validation on the manifest store. Use the `json()` method to return a JSON manifest report; If there are validation errors, the report includes a `validation_status` field.
20+
21+
Use the `resource_to_file` and `resource_to_stream` methods to write resources to a file or stream, respectively.
22+
23+
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. Retrieve binary resources such as thumbnails from the manifest data, use the `resource_to_stream` or `resource_to_file` methods using the associated `identifier` field values and a `uri`.
24+
25+
```py
26+
try:
27+
# Create a reader from a file path
28+
reader = c2pa.Reader.from_file("path/to/media_file.jpg")
29+
30+
# Print the JSON for a manifest.
31+
print("manifest store:", reader.json())
32+
33+
# Get the active manifest.
34+
manifest = reader.get_active_manifest()
35+
if manifest != None:
36+
37+
# Get the URI to the manifest's thumbnail and write it to a file
38+
uri = manifest["thumbnail"]["identifier"]
39+
reader.resource_to_file(uri, "thumbnail_v2.jpg")
40+
41+
except Exception as err:
42+
print(err)
43+
```
44+
1945
</TabItem>
2046

2147
<TabItem value="cpp" label="C++">
22-
This is how to read a manifest using C++. Do we want also want C?
48+
This is how to read a manifest using C++.
2349
</TabItem>
2450

2551
<TabItem value="node" label="Node.js">

0 commit comments

Comments
 (0)