How to get a high-quality image from an IIIFv21 API in Python?

59 Views Asked by At

I have an info.json file in the IIIFv21 format, and I want to use it to retrieve high-quality image tiles. We can use, for example, the file that is available here and looked like:

> {
  "@context" : "http://iiif.io/api/image/2/context.json",
  "@id" : "https://iiif.nli.org.il/IIIFv21/FL202979482",
  "protocol" : "http://iiif.io/api/image",
  "width" : 5414,
  "height" : 3763,
  "sizes" : [ {
    "width" : 84,
    "height" : 58
  }, {
    "width" : 169,
    "height" : 117
  }, {
    "width" : 338,
    "height" : 235
  }, {
    "width" : 676,
    "height" : 470
  }, {
    "width" : 1353,
    "height" : 940
  }, {
    "width" : 2707,
    "height" : 1881
  } ],
  "tiles" : [ {
    "width" : 1024,
    "height" : 1024,
    "scaleFactors" : [ 1, 2, 4, 8, 16, 32, 64 ]
  } ],
  "profile" : [ "http://iiif.io/api/image/2/level1.json", {
    "formats" : [ "jpg" ],
    "qualities" : [ "native", "color", "gray", "bitonal" ],
    "supports" : [ "regionByPct", "regionSquare", "sizeByForcedWh", "sizeByWh", "sizeAboveFull", "rotationBy90s", "mirroring" ],
    "maxWidth" : 526,
    "maxHeight" : 526,
    "maxArea" : 111111
  } ],
  "rights" : "http://web.nli.org.il/sites/NLI/Hebrew/library/items-terms-of-use/Pages/nli-copying-prohibited.aspx"
}

I have been trying to follow the IIIF specification, but I'm struggling to retrieve any tile. I've tried a few different approaches, but they haven't been successful.

Some of my attempts are:

  1. https://iiif.nli.org.il/IIIFv21/FL202979451/0,0,1024,1024/1024,/0/default.jpg
  2. https://iiif.nli.org.il/IIIFv21/FL202979451/0,0,1024,1024/1024,1024/0/default.jpg
  3. https://iiif.nli.org.il/IIIFv21/FL202979451/0,0/1024,1024/0/default.jpg
  4. https://iiif.nli.org.il/IIIFv21/FL202979451/0/0,0,1024,1024/1024,/0/default.jpg
  5. https://iiif.nli.org.il/IIIFv21/FL202979451/0/0,0,1024,1024/1024,1024/0/default.jpg
  6. https://iiif.nli.org.il/IIIFv21/FL202979451/0/0,0/1024,1024/0/default.jpg

You can change the values in the 1024s to match the desired tile location, but this is the top left tile.

Thank you in advance for any assistance you can provide.

1

There are 1 best solutions below

0
On

When you use image ID FL58252370 in a valid URL - for example:

https://iiif.nli.org.il/IIIFv21/FL202979482/full/max/0/default.jpg

Then you get "unauthorized" as your response:

<error>
    <parameter>unauthorized</parameter>
    <text>
        Error, no permissions, please contact administrator
    </text>
</error>

You simply do not have access to that specific image.

(Or, maybe that is not a valid image ID. But the fact that you can retrieve the info.json response suggests it should be a valid image ID.)

If you replace that image ID with the ID of a valid, publicly accessible image...

FL58252370

...then the above URL will work:

https://iiif.nli.org.il/IIIFv21/FL58252370/full/max/0/default.jpg

You can take this new ID and use it in your 6 attempts to see which URLs are valid (some of them are; some others are not).


The web site provides detailed guidance here, showing how to construct a valid image URL.

If you believe you should have access to the image for FL58252370, then I guess you need to contact the NLI.