iiif-prezi / iiif-prezi3

IIIF Presentation API 3 Python Library
https://iiif-prezi.github.io/iiif-prezi3/
Apache License 2.0
27 stars 14 forks source link

`add_image` Canvas helper creates an Annotation that targets the image URL, not the Canvas #108

Closed digitaldogsbody closed 1 year ago

digitaldogsbody commented 1 year ago

Expected behaviour:

Adding an Image onto a Canvas with the helper should produce an Annotation that targets the Canvas object.

Observed behaviour:

The Annotation targets the URI of the image.

from iiif_prezi3 import Canvas
c = Canvas()
c.add_image(image_url="https://example.com/image.jpg")
print(c.json(indent=2))

returns:

{
  "@context": "http://iiif.io/api/presentation/3/context.json",
  "id": "http://example.org/iiif/1",
  "type": "Canvas",
  "items": [
    {
      "id": "http://example.org/iiif/3",
      "type": "AnnotationPage",
      "items": [
        {
          "id": "http://example.org/iiif/2",
          "type": "Annotation",
          "motivation": "painting",
          "body": {
            "id": "https://example.com/image.jpg",
            "type": "Image"
          },
          "target": "https://example.com/image.jpg"
        }
      ]
    }
  ]
}

Potential bug location(s):

https://github.com/iiif-prezi/iiif-prezi3/blob/main/iiif_prezi3/helpers/canvas_helpers.py#L22

Any other comments: