inveniosoftware / flask-iiif

Flask-IIIF is permitting easy integration with the International Image Interoperability Framework (IIIF) API standards.
https://flask-iiif.readthedocs.io
Other
28 stars 27 forks source link

`!` parameter is not correctly calculated #47

Closed ntarocco closed 4 years ago

ntarocco commented 6 years ago

When an image resize is requested with !, the output does not respect the standard: Documentation: http://iiif.io/api/image/2.0/#size

The algorithm should match the biggest of the desired parameter and resize the image keeping the aspect ratio intact.

dfdan commented 4 years ago

Sorry to dig up an old issue, but this behaviour is still not compliant with the IIIF standard (tell me if this is better handled in a separate issue).

Per the IIIF spec (as linked above), when using !w,h as a size specification:

The image content is scaled for the best fit such that the resulting width and height are less than or equal to the requested width and height. The exact scaling may be determined by the service provider, based on characteristics including image quality and system performance. The dimensions of the returned image content are calculated to maintain the aspect ratio of the extracted region.

(emphasis mine) ie - padding / background-filling the image is not allowed here. The requesting client should be able to handle an image of some size smaller than w,h.

Examples - with the same image/parameters:

Happy to do a PR fixing this - in order to minimize impact on existing things (CERN Videos/ Zenodo?), I would propose including a config option to keep the current behaviour for implementations that expect it?

ntarocco commented 4 years ago

Interesting. It can indeed break UI things, but I would honestly avoid a config for this: I would say it is a bug. In my opinion, we can fix it (sure PR is welcome! :) ) and then decide to release it maybe as a major? We can discuss this. Ping @lnielsen @slint @kprzerwa

dfdan commented 4 years ago

Okay, thanks @ntarocco - there are a couple of other minor spec deviations which I will open seaprate issue(s) for, I can roll them up into 1 fix.

lnielsen commented 4 years ago

Yep, I'll consider it a bugs as well and just do a new release.