翻译:宋杰
原文地址:https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/
用例
本实施讨论描述了使用缩略图属性在 IIIF 清单中指定资源的缩略图的几种方法。
虽然声明缩略图不是必须的,但有几种情况下 Presentation API 3.0 推荐使用缩略图。
- 为集合或清单提供一个代表性的图像
- 当Canvas有多个资源组成视图时
- 当一个内容资源是资源选择中的一个选项时
Presentation API 3.0 并未明确推荐画布使用缩略图,因为大多数查看客户端都会从资源中渲染缩略图;不过,在画布上声明缩略图会有好处,以提高缩略图在查看器中的加载效率。这在有许多Canvases的Manifest中特别明显,比如有许多高分辨率图像的书籍和手稿。在这些情况下,当缩略图被加载到查看器中时,查看器会同时请求所有的源图像,这对图像服务器来说是一个资源密集型的任务。
缓解这些性能问题的一个选择是配置缩略图属性,为查看器客户端提供更明确的指示,说明如何处理缩略图。本实施讨论的重点是概述在Canvases上声明缩略图的最有效方法,以优化处理和渲染。这里的建议是为了指导Manifests的发布者和查看客户端的开发者。虽然这里的例子是为了优化画布上的缩略图的处理,但它们同样适用于其他IIIF资源类型(Manifest、Collection等)。关于缩略图的一般介绍,请看Manifest的图像缩略图配方。
注意:还有其他缓解此类性能问题的选项,例如预先缓存选定的图像尺寸,以便使用CDN或其他快速访问策略提供 “预热 “的缩略图;然而,这超出了本实施讨论的范围。
实施说明
最小的缩略图要求
至少,缩略图thumbnail属性需要id和type属性。强烈建议也包括格式format、高度height和宽度width属性。
"thumbnail": [
{
"id": "https://fixtures.iiif.io/video/indiana/donizetti-elixir/act1-thumbnail.png",
"type": "Image",
"format": "image/png",
"width": 640,
"height": 360
}
]
这种配置在大多数情况下并不理想,因为它没有为客户提供尺寸选择。如果提供的尺寸太小,不能满足客户的缩略图要求,调整尺寸可能会带来伪影,看起来像像素一样。在这种配置下,缩小图片的尺寸比要求完美的尺寸更可取。
上述配置最适合用于缩略图的图像不是IIIF图像的情况,如A/V材料的缩略图,出版商可能没有专门用于缩略图的IIIF图像服务器。
带有 IIIF 图像服务的缩略图
对于缩略图来自于IIIF图像的情况,建议包括一个IIIF图像API服务,以允许客户完全灵活地选择适合其界面的缩略图。关于这种方法的一个例子,请看Manifest的图像缩略图专题。
这种方法可能是集合或清单缩略图的一个很好的选择,但对于画布来说,这种方法仅仅是重复了画布资源的图像服务,而且在客户端忽略给定的缩略图尺寸而选择图像服务的情况下,我们在性能方面没有任何收获。
缩略图与IIIF图像服务+JSON图像响应尺寸
由于单独添加一个服务并没有给我们带来任何好处,我们可以更进一步,从JSON图像响应中包括所有或选择预缓存的尺寸,并将配置文件设置为0级。广告适当的预缓存尺寸为查看客户端提供了一个可用的尺寸选项列表,它可以检索而不是使用图像服务,从而优化了缩略图的生成和交付。
"thumbnail": [
{
"id": "https://fixtures.iiif.io/other/level0/Glen/photos/gottingen/full/max/0/default.jpg",
"type": "Image",
"format": "image/jpg",
"width":252,
"height":189,
"service": [
{
"id":"https://fixtures.iiif.io/other/level0/Glen/photos/gottingen",
"profile": "level0",
"type": "ImageService3",
"sizes":[
{
"width": 126,
"height": 95
},
{
"width": 252,
"height": 189
},
{
"width": 504,
"height": 378
}
]
}
]
}
]
在这个配置中,我们可能期望客户端首先尝试给定的缩略图尺寸(252x189),然后如果太小,就使用图像服务中的一个预缓存图像(252x189或504x378)。由于我们使用的是0级,客户最好选择最合适的尺寸,可能只是大一些,然后根据需要缩小图片,以最适合视图。
另外,我们可以将图像服务配置文件改为1级或2级。在这种情况下,如果预先缓存的尺寸都不合适,那么客户仍然可以在需要时请求一个自定义的尺寸。在这里,我们给客户提供了一些选择,让他们在求助于自定义图片请求之前进行尝试,但最终客户可能还是会请求自定义图片,在这种情况下,缩略图属性基本上又是在重复Canvas资源的服务;不过,这个选项可以确保在提供的尺寸对缩略图视图来说不是最佳的情况下,选择合适的缩略图尺寸。
限制
未知。
示例
下面的两个Manifest演示了Canvases上缩略图属性的使用:第一个指定了一个视频文件的缩略图,遵循最小缩略图要求选项;第二个是一个图像文件的缩略图,使用IIIF图像服务+JSON图像响应尺寸选项。注意:这里的图像缩略图指定的是0级配置文件,但如果希望为自定义尺寸留有余地,可以改为1级配置文件。
JSON-LD | 在 Mirador 中查看 | 在Uinversal Viewer中查看
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/manifest-av.json",
"type": "Manifest",
"label": {
"en": [
"Video recording of Donizetti's _The Elixir of Love_"
]
},
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/donizetti/1",
"type": "Canvas",
"label": {
"en": [
"The Elixir of Love, Act 1"
]
},
"duration": 3971.243,
"width": 640,
"height": 360,
"thumbnail": [
{
"id": "https://fixtures.iiif.io/video/indiana/donizetti-elixir/act1-thumbnail.png",
"type": "Image",
"format": "image/png",
"width": 640,
"height": 360
}
],
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/donizetti/1/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/donizetti/1/1-video",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "https://fixtures.iiif.io/video/indiana/donizetti-elixir/vae0637_accessH264_low_act_1.mp4",
"type": "Video",
"duration": 3971.243,
"width": 640,
"height": 360,
"format": "video/mp4"
},
"target": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/donizetti/1"
}
]
}
]
},
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/donizetti/2",
"type": "Canvas",
"label": {
"en": [
"The Elixir of Love, Act 2"
]
},
"duration": 3307.224,
"width": 640,
"height": 360,
"thumbnail": [
{
"id": "https://fixtures.iiif.io/video/indiana/donizetti-elixir/act2-thumbnail.png",
"type": "Image",
"format": "image/png",
"width": 640,
"height": 360
}
],
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/donizetti/2/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/donizetti/2/1-video",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "https://fixtures.iiif.io/video/indiana/donizetti-elixir/vae0637_accessH264_low_act_2.mp4",
"type": "Video",
"duration": 3307.224,
"width": 640,
"height": 360,
"format": "video/mp4"
},
"target": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/donizetti/2"
}
]
}
]
}
]
}
JSON-LD | 在 Mirador 中查看 | 在Uinversal Viewer中查看
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/manifest-image.json",
"type": "Manifest",
"label": {
"en": [
"Gänseliesel-Brunnen, Göttingen"
]
},
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/p1",
"type": "Canvas",
"label": {
"en": [
"Photo of the Gänseliesel-Brunnen taken at the 2019 IIIF Conference"
]
},
"width": 4032,
"height": 3024,
"thumbnail": [
{
"id": "https://fixtures.iiif.io/other/level0/Glen/photos/gottingen/full/max/0/default.jpg",
"type": "Image",
"format": "image/jpg",
"width": 252,
"height": 189,
"service": [
{
"id": "https://fixtures.iiif.io/other/level0/Glen/photos/gottingen",
"profile": "level0",
"type": "ImageService3",
"sizes": [
{
"width": 126,
"height": 95
},
{
"width": 252,
"height": 189
},
{
"width": 504,
"height": 378
}
]
}
]
}
],
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/page/p1/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/annotation/p0001-image",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen/full/max/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"width": 4032,
"height": 3024,
"service": [
{
"id": "https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen",
"profile": "level1",
"type": "ImageService3"
}
]
},
"target": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/p1"
}
]
}
]
},
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/p2",
"type": "Canvas",
"label": {
"en": [
"Gänseliesel-Brunnen at Night"
]
},
"width": 3024,
"height": 4032,
"thumbnail": [
{
"id": "https://fixtures.iiif.io/other/level0/Glen/photos/fountain/full/max/0/default.jpg",
"type": "Image",
"format": "image/jpg",
"width": 189,
"height": 252,
"service": [
{
"id": "https://fixtures.iiif.io/other/level0/Glen/photos/fountain",
"profile": "level0",
"type": "ImageService3",
"sizes": [
{
"width": 95,
"height": 126
},
{
"width": 189,
"height": 252
},
{
"width": 378,
"height": 504
}
]
}
]
}
],
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/page/p2/1",
"type": "AnnotationPage",
"items": [
{
"id": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/annotation/p0002-image",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-fountain/full/max/0/default.jpg",
"type": "Image",
"format": "image/jpeg",
"width": 3024,
"height": 4032,
"service": [
{
"id": "https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-fountain",
"profile": "level1",
"type": "ImageService3"
}
]
},
"target": "https://iiif.io/api/cookbook/recipe/0232-image-thumbnail-canvas/canvas/p2"
}
]
}
]
}
]
}
相关专题
- 支持深度查看,基本使用IIIF图像服务
- 清单的图像缩略图