ForHosting KIT · Video

Letterbox bar pixel size calculator for video canvases

This letterbox bar size calculator turns two aspect ratios and a canvas height into practical pixel measurements for video layouts.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter the source ratio, the target canvas ratio, and the canvas height. The result identifies whether bars belong above and below the picture or on its left and right sides, then reports the size of each equal bar. Matching ratios correctly return zero because the source already fills the canvas without cropping or padding.

Start with the source and canvas ratios

An aspect ratio describes width relative to height, so 16:9 and 1.777777 are two ways to describe the same shape. Supply the source ratio for the picture you want to preserve and the target ratio for the finished canvas. The canvas height establishes the actual pixel scale; its width is derived from the target ratio. The calculator accepts ratios written as W:H, W/H, or a positive decimal, making it suitable for common labels such as 4:3, 16:9, 21:9, and 2.39:1. Use the true display aperture when you know it rather than assuming that a marketing label is exact. For example, some formats casually called 21:9 use slightly different numerical ratios. Small ratio differences can produce visible bars at high resolutions. All dimensions must be positive and finite, and the canvas height must be a whole number of pixels. If the source and target ratios are equal, no padding is necessary, so every bar dimension is returned as zero rather than treated as an error.

Understand top-and-bottom versus side bars

The source is fitted entirely inside the canvas without stretching and without removing any picture content. When the source is wider than the target canvas, its width touches the canvas edges first. Its fitted height is then smaller than the canvas height, leaving unused space split evenly above and below the image. The result calls this orientation top_bottom and reports the height of each bar. When the source is narrower than the target canvas, its height touches first and unused horizontal space remains. That space is divided equally between the left and right sides, producing a left_right orientation and a width for each side bar. This second case is often called pillarboxing, although both cases are handled by the same fit calculation. The bar_size_pixels field always contains the size of one bar, not the combined padding. Dedicated top, bottom, left, and right fields make the result unambiguous for layout code and avoid requiring callers to interpret the orientation before assigning padding.

Apply the result in editing and rendering workflows

Use the returned dimensions when preparing overlays, preview frames, encoded masters, projection layouts, or CSS and canvas compositions. The calculator reports fractional pixels when the geometry does not divide evenly, rounded deterministically to six decimal places. A rendering tool that requires integer coordinates must choose its own rounding policy because rounding both bars independently can otherwise make the final dimensions differ by one pixel. A practical raster workflow may floor one edge and assign the remaining pixel to the opposite edge, while a vector or browser layout can often keep the fractional value. The calculation assumes a centered contain fit: it preserves the complete source, does not crop, and places equal padding on opposing sides. It does not account for anamorphic pixel aspect ratios, rotation metadata, overscan, or safe-area guides; convert those into an effective source display ratio before using this tool. API automation costs $0.002 per request, while the same deterministic calculation can be exposed in a browser runner without sending media files anywhere.

Prepare a cinematic video for a standard frame

Calculate equal top and bottom padding before placing a wide source inside a 16:9 delivery canvas.

Build a pillarboxed archive master

Find the left and right bar widths needed to preserve older 4:3 footage in a modern widescreen frame.

Position graphics outside the active picture

Reserve known bar dimensions for captions, labels, or controls without covering the fitted source image.

What happens when both aspect ratios are equal?

The result uses the none orientation and returns zero for every bar dimension because no bars are needed.

Is bar_size_pixels one bar or both bars together?

It is the size of one bar. Opposing bars are equal, and the dedicated edge fields report each one explicitly.

Why can the result contain a fractional pixel?

Aspect-ratio geometry does not always divide into whole pixels. The result preserves the accurate value so your renderer can apply its preferred rounding policy.

Does this calculation crop or stretch the source?

No. It uses a centered contain fit that preserves the entire source and its original display proportions.

What does an API calculation cost?

Each API request costs $0.002. The calculation is deterministic and does not upload or inspect a video file.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/video2/aspect-ratio-letterbox-bars-size

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/video2/aspect-ratio-letterbox-bars-size \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"source_aspect_ratio":"21:9","target_aspect_ratio":"16:9","canvas_height":1080}'
{
  "source_aspect_ratio": "21:9",
  "target_aspect_ratio": "16:9",
  "canvas_height": 1080
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "video2.aspect_ratio_letterbox_bars_size",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb500
max_minutes60
max_megapixels3.9
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →