kitodo / kitodo-presentation

Kitodo.Presentation is a feature-rich framework for building a METS- or IIIF-based digital library. It is part of the Kitodo Digital Library Suite.
https://kitodo.org
GNU General Public License v3.0
38 stars 44 forks source link

Zoom level issues with IIIF images #306

Closed lutzhelm closed 5 years ago

lutzhelm commented 5 years ago

In dlfViewerSource.IIIF, a value for maxZoom is calculated that is later used by the source to determine the correct scale for a given zoom level.

https://github.com/kitodo/kitodo-presentation/blob/e78f28458927a90f1249b0bef795a9685c630ec7/plugins/pageview/tx_dlf_ol3_source.js#L93-L97

If the zoom levels from 0 to maxZoom and the reverse values in resolutions (which originate from the IIIF image scale factors) do not correspond, the IIIF tile source will provide tiles for the wrong zoom level.

An Example

Possible solution

I could provide a pull request for that solution.

lutzhelm commented 5 years ago

I've put the example image (and two other random examples with the same problem) into a little demo: https://lutzhelm.github.io/kitodo-presentation-306.html

The following shows the behaviour with maxZoom calculated from the maximum resolution: https://lutzhelm.github.io/kitodo-presentation-306-working.html

lutzhelm commented 5 years ago

While the solution I suggested improves the viewers behaviour and using powers of 2 as resolutions if no scaleFactors are given will work smoothly, there remains the problem that the scaleFactors provided by an info.json do not have to be consecutive values of powers to 2. In fact, any positive integer is allowed. This is bound to cause conflicts with OpenLayers whose default zoomFactor 2 will not work together with an arbitrary set of scaleFactors provided by an info.json.

So additionally I'd suggest that the scaleFactors are to be ignored if they are not a consecutive sequence of powers to 2 after sorting. In that case the viewer should provide a set of resolutions calculated from maxZoom. Size by percentage must be supported by all IIIF image servers at level 1 and 2, so the only problem may be performance issues if the calculated resolutions perform worse than the scaleFactors from the image's info.json.

lutzhelm commented 5 years ago

I have updated the working demo with the solution from the pull request.