From c11c258d94cb03e886909f83904b0c0190362881 Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Sun, 8 Dec 2024 20:35:53 -0600 Subject: [PATCH 1/2] Add solution for recipe_0036. --- docs/recipes/0036-composition-from-multiple-images.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/recipes/0036-composition-from-multiple-images.md diff --git a/docs/recipes/0036-composition-from-multiple-images.md b/docs/recipes/0036-composition-from-multiple-images.md new file mode 100644 index 0000000..e879be6 --- /dev/null +++ b/docs/recipes/0036-composition-from-multiple-images.md @@ -0,0 +1,10 @@ +# Composition from Multiple Images +| | **Cookbook URLs** | +|--------------|-------------------| +| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0036-composition-from-multiple-images/](https://iiif.io/api/cookbook/recipe/0036-composition-from-multiple-images/) | +| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0036-composition-from-multiple-images/manifest.json](https://iiif.io/api/cookbook/recipe/0036-composition-from-multiple-images/manifest.json) | + +### Method 1 - Add Multiple Annotations with add_item() helper +```python +--8<-- "docs/recipes/scripts/0036-composition-from-multiple-images-method1.py" +``` From 388545b9c952dfa068626bb1d198ed78c6043470 Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Sun, 8 Dec 2024 20:36:27 -0600 Subject: [PATCH 2/2] Add solution for recipe_0036. --- ...omposition-from-multiple-images-method1.py | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 docs/recipes/scripts/0036-composition-from-multiple-images-method1.py diff --git a/docs/recipes/scripts/0036-composition-from-multiple-images-method1.py b/docs/recipes/scripts/0036-composition-from-multiple-images-method1.py new file mode 100644 index 0000000..b77b8bb --- /dev/null +++ b/docs/recipes/scripts/0036-composition-from-multiple-images-method1.py @@ -0,0 +1,63 @@ +from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, config + +config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en" +base_url = "https://iiif.io/api/cookbook/recipe/0036-composition-from-multiple-images" + +manifest = Manifest( + id=f"{base_url}/manifest.json", + label="Folio from Grandes Chroniques de France, ca. 1460" +) +canvas = manifest.make_canvas( + id=f"{base_url}/canvas/p1", + height=5412, + width=7216 +) +canvas.add_label(language="none", value="f. 033v-034r [Chilpéric Ier tue Galswinthe, se remarie et est assassiné]") + +anno_body_a = ResourceItem( + id="https://iiif.io/api/image/3.0/example/reference/899da506920824588764bc12b10fc800-bnf_chateauroux/full/max/0/default.jpg", + type="Image", + format="image/jpeg", + height=5412, + width=7216 +) +anno_body_a.make_service( + id="https://iiif.io/api/image/3.0/example/reference/899da506920824588764bc12b10fc800-bnf_chateauroux", + type="ImageService3", + profile="level1" +) +anno_page = AnnotationPage( + id=f"{base_url}/page/p1/1" +) +annotation_a = Annotation( + id=f"{base_url}/annotation/p0001-image", + motivation="painting", + body=anno_body_a, + target=canvas.id +) + +anno_body_b = ResourceItem( + id="https://iiif.io/api/image/3.0/example/reference/899da506920824588764bc12b10fc800-bnf_chateauroux_miniature/full/max/0/default.jpg", + type="Image", + format="image/jpeg", + width=2138, + height=2414 +) +anno_body_b.add_label(language="fr", value="Miniature [Chilpéric Ier tue Galswinthe, se remarie et est assassiné]") +anno_body_b.make_service( + id="https://iiif.io/api/image/3.0/example/reference/899da506920824588764bc12b10fc800-bnf_chateauroux_miniature", + type="ImageService3", + profile="level1" +) +annotation_b = Annotation( + id=f"{base_url}/annotation/p0002-image", + motivation="painting", + body=anno_body_b, + target=f"{canvas.id}#xywh=3949,994,1091,1232" +) + +anno_page.add_item(annotation_a) +anno_page.add_item(annotation_b) +canvas.add_item(anno_page) + +print(manifest.json(indent=2)) \ No newline at end of file