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
### Reading ingredient details from an ingredient archive
687
+
688
+
An ingredient archive is a serialized `Builder` containing exactly one and only one ingredient (see [Builder archives vs. ingredient archives](#builder-archives-vs-ingredient-archives)). Reading it with `Reader` allows the caller to inspect the ingredient before deciding whether to use it: its thumbnail, whether it carries provenance (e.g. an active manifest), validation status, relationship, etc.
// thumb_stream now contains the thumbnail binary data
746
+
}
747
+
```
748
+
749
+
#### Linking an archived ingredient to an action
750
+
751
+
After reading the ingredient details from an ingredient archive, the ingredient can be added to a new `Builder` and linked to an action. The preferred approach is to assign a `label` in the `add_ingredient` call and use that label as the linking key in `ingredientIds`. If the archived ingredient carries an `instance_id`, you can use that instead.
752
+
753
+
Note that labels are only used as build-time linking keys. The SDK may reassign the actual label in the signed manifest. An `instance_id`, on the other hand, is preserved as-is through signing and can be read back unchanged from the final manifest.
754
+
755
+
##### Using a label
756
+
757
+
Assign a `label` in the `add_ingredient` call and reference that same label in `ingredientIds`. This works whether or not the ingredient has an `instance_id`.
// The label on the ingredient JSON matches the entry in ingredientIds
792
+
archive_file.seekg(0);
793
+
builder.add_ingredient(
794
+
json({
795
+
{"title", ingredient["title"]},
796
+
{"relationship", "parentOf"},
797
+
{"label", "archived-ingredient"}
798
+
}).dump(),
799
+
"application/c2pa",
800
+
archive_file);
801
+
802
+
builder.sign(source_path, output_path, signer);
803
+
```
804
+
805
+
##### Using an `instance_id`
806
+
807
+
If the ingredient archive carries an `instance_id` and you need a stable identifier that persists unchanged in the signed manifest, you can use the `instance_id` as the linking key in `ingredientIds` instead of a label.
808
+
809
+
```cpp
810
+
c2pa::Context context;
811
+
812
+
// Read the ingredient archive and extract the instance_id
In some cases you may need to merge ingredients from multiple working stores (builder archives) into a single `Builder`. This should be a **fallback strategy**—the recommended practice is to maintain a single active working store and add ingredients incrementally (archived ingredient catalogs help with this). Merging is available when multiple working stores must be consolidated.
0 commit comments