Skip to content

Main content

Adslot Aspect Ratio Letterbox Tool

Fit content proportionally within an ad slot and report combined top/bottom and left/right bar sizes, without cropping.

Loading tool…

Description

Choose the smaller slot-to-content width and height ratio, multiply both content dimensions by that scale, and subtract displayed dimensions from slot dimensions.

Fitting rectangular content inside a slot preserves its aspect ratio by using the smaller axis scale. The unused width or height becomes a margin rather than a crop.

Choose the smaller slot-to-content width and height ratio, multiply both content dimensions by that scale, and subtract displayed dimensions from slot dimensions.

When to use this tool

Use Adslot Aspect Ratio Letterbox when you need the dimensions and unused space of an ideal rectangular fit.

How to use the tool and how it works

  1. Enter contentWidth, contentHeight, slotWidth, slotHeight. 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 scale, displayedWidth, displayedHeight, horizontalBarTotal, verticalBarTotal. Use the output convention below.

Choose the smaller slot-to-content width and height ratio, multiply both content dimensions by that scale, and subtract displayed dimensions from slot dimensions.1

Input fieldMeaning and unitsAccepted input
contentWidthContent WidthRequired. Finite number; strictly above 0.
contentHeightContent HeightRequired. Finite number; strictly above 0.
slotWidthSlot WidthRequired. Finite number; strictly above 0.
slotHeightSlot HeightRequired. Finite number; strictly above 0.
Output fieldInterpretationReturned shape
scaleScaleRequired. Finite number.
displayedWidthDisplayed WidthRequired. Finite number.
displayedHeightDisplayed HeightRequired. Finite number.
horizontalBarTotalUnused slot height, combining top and bottom bars.Required. Finite number.
verticalBarTotalUnused slot width, combining left and right bars.Required. Finite number.
json
{
  "input": {
    "contentWidth": 16,
    "contentHeight": 9,
    "slotWidth": 100,
    "slotHeight": 100
  },
  "output": {
    "scale": 6.25,
    "displayedWidth": 100,
    "displayedHeight": 56.25,
    "horizontalBarTotal": 43.75,
    "verticalBarTotal": 0
  }
}

Limitations and assumptions

  • All dimensions are positive and use compatible units. horizontalBarTotal is unused height and verticalBarTotal is unused width, each combining both bars rather than one side; no cropping or pixel rounding is performed.
  • 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

Inspect the final layout in its target renderer and apply any pixel rounding or production constraints separately.

References

  1. Calculation and input contract: advertising/adslot-aspect-ratio-letterbox — tool.io

Similar or alternative tools

  • Whole Slide Tile Overlap Pixel Budget

    Subtract overlap once between adjacent tiles for mosaic dimensions and compare mosaic pixel area with summed tile areas for pixelsSaved.

  • Turtle Shell Photo Area Factor

    Convert nonnegative pixelArea using squared scaleLength/scalePixels, then divide projectedArea by cosine(obliquityRadians), with angle strictly within ±π/2.