ForHosting KIT · Images

Add border to image dimensions

Adding a border changes an image’s canvas size even though the original picture remains untouched inside it.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

This calculator takes the original pixel width and height, applies the same border width to the top, right, bottom, and left, and returns the exact outer dimensions. It also preserves the supplied color in the result so the calculation can travel with a design specification, export job, or automated image workflow.

Calculate the canvas size before exporting

A border occupies space outside each edge of the original image. That means a 20-pixel border does not add only 20 pixels to the width or height: it adds 20 pixels on the left and another 20 on the right, plus 20 at both the top and bottom. Enter the original width and height in pixels, the width of one border edge, and the intended color. The calculator returns the original measurements alongside the new outer width and outer height, making the change easy to review. This is useful before opening an image editor, preparing a batch-processing rule, or reserving space in a page layout. The calculation does not resize, crop, stretch, or encode an image. It answers the dimensional question only, so there is no ambiguity about whether the original content area has changed. A zero-width border is accepted and leaves both outer dimensions equal to the original dimensions, which can help software use one consistent calculation path even when no visible border is needed.

Understand the border formula

The formula is deliberately simple and predictable: outer width equals original width plus twice the border width, while outer height equals original height plus twice the border width. Multiplication by two accounts for the two opposite sides on each axis. For example, an image that is 1200 pixels wide and 800 pixels high with a 24-pixel border becomes 1248 by 848 pixels. The color does not affect either dimension, but it is returned so downstream code can keep the visual setting together with the measurements. Original width and height must be positive whole numbers because pixel dimensions describe a real raster canvas. Border width may be zero or a positive finite number, allowing calculations for workflows that support fractional layout measurements as well as ordinary whole pixels. Negative borders are rejected because they would describe cropping or inset geometry, not adding an outer border. Use a separate crop calculation when the goal is to remove pixels from the image edges.

Use the result in design and automation

The returned outer dimensions can be passed directly into layout planning, canvas creation, asset validation, or storage estimates. A developer can calculate the required canvas before drawing the original image at the border offset. A designer can verify that a framed thumbnail still fits a fixed card or marketplace slot. A production team can compare the result with a maximum upload size before processing thousands of assets. Because the operation uses only deterministic arithmetic, identical inputs always produce identical results, with no network request, file upload, random value, or hidden image transformation involved. The supplied color is treated as a label rather than interpreted or converted, so values such as a hexadecimal code, a CSS color name, or a workflow-specific token can remain intact after surrounding whitespace is removed. The API price is $0.002 per request. The response reports both original and outer measurements, which makes logs self-explanatory and reduces the risk of confusing source dimensions with the final bordered canvas.

Prepare a bordered canvas

Calculate the exact canvas dimensions needed before placing an unchanged source image inside a newly colored border.

Validate marketplace assets

Check whether a product image will remain within an upload or layout limit after a uniform border is added.

Plan batch image jobs

Generate predictable output dimensions for automated pipelines before committing resources to rendering every image.

How are the new dimensions calculated?

Twice the border width is added to both dimensions because the border appears on two sides of each axis.

Does this capability modify or upload my image?

No. It receives dimensions and border settings only, then returns calculated measurements without reading or changing an image file.

Can the border width be zero?

Yes. A zero-width border is valid and returns outer dimensions equal to the original dimensions.

What happens if the border width is negative?

The request fails with an invalid input error because a negative value describes removing or insetting space rather than adding an outer border.

Which color formats can I provide?

You can provide any non-empty color label, including a CSS name, hexadecimal notation, or a token used by your own workflow. The value is preserved, not interpreted.

What does an API calculation cost?

Each API request costs $0.002. The calculation is also suitable for the generated browser runner because it requires no network access.

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/image/add-border

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/image/add-border \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"width":1200,"height":800,"border_width":24,"color":"#1d4ed8"}'
{
  "width": 1200,
  "height": 800,
  "border_width": 24,
  "color": "#1d4ed8"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "image.add_border",
  "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_mb15
max_megapixels12
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 →