craigsapp / website-polish-scores

Front-end for digital transcriptions of the Polish Music Heritage in Open Access project
https://polishscores.org
3 stars 1 forks source link

IIIF images from NIFC don't work #217

Closed jacekiwaszko1 closed 1 year ago

jacekiwaszko1 commented 1 year ago

Hi Craig, do you know why clicking on a note in VHV displays the IIIF image from the NIFC server, and on polishscores.org doesn't?

Here's the example from polishscores.org: https://polishscores.org/?id=16xx:904 And here is the same file in VHV: https://verovio.humdrum.org/?file=https%3A%2F%2Fdata.nifc.humdrum.org%2F16xx%3A904.krn

craigsapp commented 1 year ago

Demo in VHV (clicking on the first note of the altus part):

Screenshot 2023-04-14 at 9 17 06 AM

Trying to do the same thing on polishscores.org:

Screenshot 2023-04-14 at 9 20 17 AM

getIfffBase() and getIiifManifestInfo() are being called.

Check to see if/where errors are occurring in one of these two functions.

jacekiwaszko1 commented 1 year ago

Hi Craig, I ran some tests and it looks like the problem lies in establishing iiifbase, which is adjusted to IIIF v.3 manifests. NIFC repository system uses version 2 of IIIF, therefore manifests I generate are based on IIIF v. 2.

There are some differences between v.2 and v.3 - the most important is probably the change of id label (@id -> id) as well as moving the list of objects from sequences[n].canvases to items.

It is also possible, that the manifests generated by me are not correct (see https://repozytorium.nifc.pl/islandora/object/pl-kk%3A1956/datastream/IIIF/view). If you think that something should be fixed there I can do that (There are only 34 IIIF manifests uploaded for now).

On VHV iiifbase is defined correctly based on my manifests, so maybe it would be possible to use a similar system on polishscores?

craigsapp commented 1 year ago

The problem is most likely a difference between IIIF v3 and v2. NIFC manifests are then in v2 and Polona are in v3 formats.

Now the NIFC-hosted Manifest are being read correct to extract image information, and double-clicking on notes will display the staff on which the note is found in the source scan:

https://polishscores.org/?id=16xx:900

Screenshot 2023-04-27 at 7 31 01 PM

In NIFC Manifests the image information is found here:

 manifest.sequences[0].canvases[*].images[0].resource.service["@id"]

such as in this case:

https://repozytorium.nifc.pl/cantaloupe/iiif/2/pl-kk%3A1957~JP2~Si4gSXdhc3prbyAyMDIx

or more properly after a redirect:

https://repozytorium.nifc.pl/cantaloupe/iiif/2/pl-kk%3A1957~JP2~Si4gSXdhc3prbyAyMDIx/info.json

and then the image is extracted from the "@id" entry in the info.json file:

https://repozytorium.nifc.pl/cantaloupe/iiif/2/pl-kk:1957~JP2~Si4gSXdhc3prbyAyMDIx

with the final extracted image URL being (after also extracting the width of the image from the info.json as well):

https://repozytorium.nifc.pl/cantaloupe/iiif/2/pl-kk%3A2265~JP2~Si4gSXdhc3prbyAyMDIx/7340,3506,6110,1347/full/0/default.jpg

For Polona, the location is more direct, being found in manifest.items.

I also add a spinning cursor while downloading the image, since it takes time for the manifest, the image info and then the image itself to be downloaded. The manifest is cached, so a second image for the same work will be downloaded slightly faster since that download step is skipped.

I am printing the manifest contents in the web browser console in case of other problems most likely due to a different location for the image info in a manifest:

Screenshot 2023-04-27 at 7 32 51 PM