From 56c911eb0869b419a2b874d3de549fa95397e81d Mon Sep 17 00:00:00 2001 From: BernhardKoschicek Date: Mon, 13 Nov 2023 16:39:47 +0100 Subject: [PATCH] changed mimetype in iiif manifest and added libvips-tools to install --- install.md | 2 +- openatlas/api/endpoints/iiif.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/install.md b/install.md index 2379a89ea..97c890dd7 100644 --- a/install.md +++ b/install.md @@ -134,7 +134,7 @@ high-quality, attributed digital objects online at scale. Be aware that: ### Installation - sudo apt install iipimage-server libvips + sudo apt install iipimage-server libvips-tools sudo service apache2 restart You can test http://your.server/iipsrv/iipsrv.fcgi to see if it runs. diff --git a/openatlas/api/endpoints/iiif.py b/openatlas/api/endpoints/iiif.py index 05eee4d2c..40b7deef0 100644 --- a/openatlas/api/endpoints/iiif.py +++ b/openatlas/api/endpoints/iiif.py @@ -1,3 +1,4 @@ +import mimetypes from typing import Any import requests @@ -42,6 +43,7 @@ def get(id_: int) -> Response: @staticmethod def build_canvas(metadata: dict[str, Any]) -> dict[str, Any]: entity = metadata['entity'] + mime_type, _ = mimetypes.guess_type(g.files[entity.id]) return { "@id": url_for( 'api.iiif_canvas', id_=entity.id, version=2, _external=True), @@ -57,7 +59,7 @@ def build_canvas(metadata: dict[str, Any]) -> dict[str, Any]: "thumbnail": { "@id": f'{metadata["img_url"]}/full/!200,200/0/default.jpg', "@type": "dctypes:Image", - "format": "image/jpeg", + "format": mime_type, "height": 200, "width": 200, "service": { @@ -75,6 +77,7 @@ def get(id_: int) -> Response: @staticmethod def build_image(metadata: dict[str, Any]) -> dict[str, Any]: id_ = metadata['entity'].id + mime_type, _ = mimetypes.guess_type(g.files[id_]) return { "@context": "https://iiif.io/api/presentation/2/context.json", "@id": @@ -84,7 +87,7 @@ def build_image(metadata: dict[str, Any]) -> dict[str, Any]: "resource": { "@id": metadata['img_url'], "@type": "dctypes:Image", - "format": "image/jpeg", + "format": mime_type, "service": { "@context": "https://iiif.io/api/image/2/context.json", "@id": metadata['img_url'],