Skip to content

iiifUri can request resizes that exceed the image's size

The element creation modal (shown after drawing a polygon), element edition modal (when clicking the edit button in the tree) or transcription edition modal all use the ElementImage component to display the element's polygon standalone on the image. This element adds 25px of margins around the element's bounding box; this means that when the polygon spans the whole image, the bounding box starts at a negative coordinate and exceeds the image's size.

iiifUri handles the negative coordinates but cannot handle the excessive size as it does not have access to the image's full size. Luckily, most IIIF servers ignore the excessive cropping (as specified in the IIIF specification) and just return the full image, but iiifUri does not only do some cropping, it also does some resizing.

When a resize is set with imageWidth and/or imageHeight, one of the following situations can occur:

  • If at least width or height are set, iiifUri can determine if the resize might exceed the crop's true size and will try to compute a ratio to limit the resize to the image's size.
    • If only one of width or height are set, or if the crop's size equals or exceeds the image's size, this limit may not work and still result in a resize above 100%.
  • If none of width and height are set, iiifUri cannot try to guess the image's size and cannot limit any resize.

This can result in situations where the image does not display at all (like requests#418), due to the server returning an error. The IIIF spec says this should be a HTTP 400, but most servers are non-compliant; some will return 403, some 404, some 500, some a HTTP 200 with an error message in the body, etc.

Fixing this issue probably requires a rewrite of iiifUri.