Skip to content

Main content

IIIF Size Confined Box Factor Tool

Aspect-preserving continuous confined-box dimensions; final integer raster rounding remains a consuming-app choice.

Loading tool…

Description

Fit an image into a supplied bounding box while preserving aspect ratio.

IIIF-related selectors describe image regions, canvas coordinates and media intervals. A local arithmetic helper can use a restricted syntax or rounding convention while a full IIIF request must satisfy the API and server behavior.

Fit an image into a supplied bounding box while preserving aspect ratio.

When to use this tool

Use IIIF Size Confined Box Factor when checking the stated image-region, scaling or media-range convention.

How to use the tool and how it works

  1. Enter width, height, boxWidth, boxHeight, allowUpscale. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read factor, outputWidth, outputHeight. Use the output convention below.

Fit an image into a supplied bounding box while preserving aspect ratio. Require positive dimensions; factor = min(boxWidth/width,boxHeight/height), capped at one unless allowUpscale. Return factor and scaled dimensions.1

IIIF distinguishes image size constraints and upscaling behavior. The returned factor is local arithmetic, without a server request or pixel rounding.2

Input fieldMeaning and unitsAccepted input
widthExtent on the stated coordinate or temporal basis.Required. Finite number; strictly above 0.
heightHeightRequired. Finite number; strictly above 0.
boxWidthBox WidthRequired. Finite number; strictly above 0.
boxHeightBox HeightRequired. Finite number; strictly above 0.
allowUpscaleAllow UpscaleRequired. Boolean.
Output fieldInterpretationReturned shape
factorFactorRequired. Finite number.
outputWidthOutput WidthRequired. Finite number.
outputHeightOutput HeightRequired. Finite number.
json
{
  "input": {
    "width": 400,
    "height": 200,
    "boxWidth": 100,
    "boxHeight": 100,
    "allowUpscale": false
  },
  "output": {
    "factor": 0.25,
    "outputWidth": 100,
    "outputHeight": 50
  }
}

Limitations and assumptions

  • Dimensions remain numeric without pixel rounding; no IIIF request or actual image is generated.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use a conforming IIIF client and actual manifest or image information for complete request validation and resource access.

References

  1. Calculation and input contract: digital-humanities/iiif-size-confined-box-factor — tool.io

  2. IIIF Image API 3.0: size — IIIF Consortium

Similar or alternative tools