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
- Enter contentWidth, contentHeight, slotWidth, slotHeight. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- 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 field | Meaning and units | Accepted input |
|---|---|---|
| contentWidth | Content Width | Required. Finite number; strictly above 0. |
| contentHeight | Content Height | Required. Finite number; strictly above 0. |
| slotWidth | Slot Width | Required. Finite number; strictly above 0. |
| slotHeight | Slot Height | Required. Finite number; strictly above 0. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| scale | Scale | Required. Finite number. |
| displayedWidth | Displayed Width | Required. Finite number. |
| displayedHeight | Displayed Height | Required. Finite number. |
| horizontalBarTotal | Unused slot height, combining top and bottom bars. | Required. Finite number. |
| verticalBarTotal | Unused slot width, combining left and right bars. | Required. Finite number. |
{
"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
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.