Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Recipe_0266: Simplest Annotation #220

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/recipes/0266-full-canvas-annotation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Simplest Annotation
| | **Cookbook URLs** |
|--------------|-------------------|
| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/](https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/) |
| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json](https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/manifest.json) |

### Method 1 - Use make_annotation() helper
```python
--8<-- "docs/recipes/scripts/0266-full-canvas-annotation-method1.py"
```
52 changes: 52 additions & 0 deletions docs/recipes/scripts/0266-full-canvas-annotation-method1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from iiif_prezi3 import Manifest, ResourceItem, ResourceItem1, AnnotationPage, Annotation, config

config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en"
base_url = "https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation"

manifest = Manifest(
id=f"{base_url}/manifest.json",
label="Picture of Göttingen taken during the 2019 IIIF Conference",
)

anno_page = AnnotationPage(
id=f"{base_url}/canvas-1/annopage-1"
)
painting_body = ResourceItem(
id="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen/full/max/0/default.jpg",
type="Image",
format="image/jpeg",
)
painting_body.make_service(
id="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen",
type="ImageService3",
profile="level1"
)
painting_anno = Annotation(
id=f"{base_url}/canvas-1/annopage-1/anno-1",
motivation="painting",
body=painting_body,
target=f"{base_url}/canvas-1"
)
anno_page.add_item(painting_anno)
hw = {"height": 3024, "width": 4032}
canvas = manifest.make_canvas(
id=f"{base_url}/canvas-1",
)
painting_body.set_hwd(**hw)
canvas.set_hwd(**hw)
canvas.add_item(anno_page)
anno_body = ResourceItem1(
type="TextualBody",
language="de",
format="text/plain",
value="Göttinger Marktplatz mit Gänseliesel Brunnen"
)
anno = canvas.make_annotation(
id=f"{base_url}/canvas-1/annopage-2/anno-1",
motivation="commenting",
body=anno_body,
target=canvas.id,
anno_page_id=f"{base_url}/canvas-1/annopage-2"
)

print(manifest.json(indent=2))
Loading