|
1 | 1 | --- |
2 | 2 | id: read |
3 | 3 | title: Reading manifest data |
| 4 | +hide_table_of_contents: true |
4 | 5 | --- |
5 | 6 |
|
6 | 7 | import Tabs from '@theme/Tabs'; |
|
57 | 58 | # Create a reader from a file path |
58 | 59 | reader = c2pa.Reader.from_file("path/to/media_file.jpg") |
59 | 60 |
|
| 61 | + # Alternatively, create a reader from a stream |
| 62 | + stream = open("path/to/media_file.jpg", "rb") |
| 63 | + reader = c2pa.Reader("image/jpeg", stream) |
| 64 | + |
60 | 65 | # Print the JSON for a manifest. |
61 | 66 | print("manifest store:", reader.json()) |
62 | 67 |
|
63 | | - # Get the active manifest. |
64 | | - manifest = reader.get_active_manifest() |
65 | | - if manifest != None: |
66 | | - |
67 | | - # Get the URI to the manifest's thumbnail and write it to a file |
68 | | - uri = manifest["thumbnail"]["identifier"] |
69 | | - reader.resource_to_file(uri, "thumbnail_v2.jpg") |
70 | | -
|
71 | 68 | except Exception as err: |
72 | 69 | print(err) |
73 | 70 | ``` |
@@ -103,7 +100,7 @@ await read('my-c2pa-file.jpg', 'image/jpeg'); |
103 | 100 |
|
104 | 101 | <TabItem value="cpp" label="C++"> |
105 | 102 |
|
106 | | -Use the `read_file` function to read C2PA data from the specified file. This function examines the specified asset file for C2PA data and its return value is a JSON report if it finds C2PA data. If there are validation errors, the report includes a `validation_status` field. Exceptions are thrown on errors. |
| 103 | +Use the `read_file` function to read C2PA data from the specified file. This function examines the specified asset file for C2PA data and returns a JSON report if it finds any; it throws exceptions on errors. If there are validation errors, the report includes a `validation_status` field. |
107 | 104 |
|
108 | 105 | ```cpp |
109 | 106 | auto json_store = C2pa::read_file("<ASSET_FILE>", "<DATA_DIR>") |
|
0 commit comments