ruven / iipsrv

iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images.
https://iipimage.sourceforge.io
GNU General Public License v3.0
292 stars 115 forks source link

IIIF - last (non-square) tile in each row has incorrect (bigger) height #237

Closed filak closed 2 years ago

filak commented 2 years ago

I have this image:

{
"@context": "http://iiif.io/api/image/2/context.json",
"protocol": "http://iiif.io/api/image",
"width": 2609,
"height": 3424,
"sizes": [
{
"width": 163,
"height": 214
},
{
"width": 326,
"height": 428
},
{
"width": 652,
"height": 856
},
{
"width": 1304,
"height": 1712
}
],
"tiles": [
{
"width": 256,
"height": 256,
"scaleFactors": [
1,
2,
4,
8,
16
]
}
],
"@id": "http://iip.test/iiif/f.jp2",
"profile": [
"http://iiif.io/api/image/2/level2.json",
{
"formats": [
"jpg",
"png",
"webp"
],
"qualities": [
"native",
"color",
"gray",
"bitonal"
],
"supports": [
"regionByPct",
"regionSquare",
"sizeByForcedWh",
"sizeByWh",
"sizeAboveFull",
"sizeUpscaling",
"rotationBy90s",
"mirroring"
],
"maxWidth": 3500,
"maxHeight": 3500
}
]
}

When used with Openseadragon viewer I get these IIIF API calls:

First row:

Second row:

The content of the last tile column appears dropped a bit when zoomig out or on a small displays.

iip_iiif_osd

ruven commented 2 years ago

It looks to me like a bug in Openseadragon.

Your image is 2609x3424 pixels in size and the region requested by http://iip.test/iiif/f.jp2/2048,0,561,2048/71,/0/default.jpg is for a region of 561 pixels in width. It's using a "tile" width of 2048 for the first IIIF request (left tile on the full-size image) and if we calculate the size of this right tile, we get 2609-2048 = 561, which is indeed what it asks for, so this part is correct.

If we now look at the size parameter of the IIIF request, for the left tile it asks for a tile of size 256 in width, so it's asking for a resolution 1/8 of the size of the original image. Indeed info.json advertises tiles with size 256x256 at scale factors of 1,2,4,8,16, so asking for a scale factor of 8 is good. But, 561/8 = 70.125 not 71. For some reason, Openseadragon is rounding up rather than to the nearest integer. If you change your IIIF request slightly and replace 71 with 70, it works as it should and you get the correct height of 172 pixels. This works similarly with the second row of tiles.

Even if Openseadragon is using the sizes list in the info.json, rather than calculating using the full size, it's still wrong, as this 1/8 resolution is advertised as having size:

{
"width": 326,
"height": 428
},

So, the size of the 2nd tile in the top row should be 326-256 = 70

filak commented 2 years ago

Thank you for the analysis, I will create an issue at the OSD repo.