ForHosting KIT · Images

Resize image to dimensions

Resize Image to Dimensions calculates the pixel size an image should have after resizing.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Provide the original width and height, then enter a target width, a target height, or both. When you provide only one target dimension, the calculator derives the other dimension from the original aspect ratio and rounds it to the nearest whole pixel. When you provide both, it returns those exact dimensions. The result is deterministic and useful for image pipelines, responsive layouts, upload validation, and command generation without uploading or decoding an image.

Calculate a proportional size from one target

Start with the source image width and height in pixels. Then provide either target_width or target_height. The calculator divides the chosen target dimension by its matching original dimension to find the scale, applies that scale to the other side, and rounds the calculated result to the nearest whole pixel. For example, a 1920 by 1080 image resized to a width of 1280 becomes 1280 by 720. This approach preserves the source aspect ratio as closely as integer pixels allow, so circles remain circular and subjects do not look stretched. It is especially useful when a layout fixes one axis but lets the other adapt, such as a blog column with a fixed width or a gallery with a fixed row height. The tool calculates dimensions only: it does not upload, decode, resample, crop, compress, or alter the image itself. You can pass the returned width and height to an image library, a command-line processor, a content pipeline, or a browser rendering rule.

Use both targets when an exact box is required

Provide both target_width and target_height when the destination requires an exact pixel box. In this mode, the calculator returns the two requested values directly. It does not silently adjust either value to preserve the original aspect ratio, because doing so would violate the explicit dimensions you supplied. That distinction matters for ad inventory, marketplace listings, print templates, display hardware, and legacy systems that accept only one fixed canvas size. If the target ratio differs from the source ratio, an image processor must choose what happens next: stretch the image, crop it to fill the box, or fit it inside the box with empty space. This capability intentionally does not make that visual decision. It gives you a clear, predictable dimension result that downstream code can use with an explicit resize strategy. Compare the source and target ratios before stretching sensitive artwork, photographs, logos, diagrams, or text, since visible distortion may otherwise occur.

Handle pixels, rounding, and validation reliably

All four dimensions are positive integers because raster image sizes are expressed as whole pixels. Original width and height are always required, and at least one target dimension must be present. Zero, negative values, fractions, non-numeric values, and dimensions above the published one-billion-pixel input limit are rejected instead of being coerced. When one target is provided, the calculated side uses standard nearest-integer rounding and never falls below one pixel. Rounding can make the returned ratio differ microscopically from the mathematical ratio for very small images, which is unavoidable when a fractional pixel cannot exist. For repeatable automation, send the original pixel dimensions reported by the image metadata rather than CSS display dimensions or a manually estimated size. The same input always produces the same output: there is no network access, random behavior, current-time dependency, image inspection, or hidden state. That makes the result safe to cache, test in golden fixtures, and reuse across API clients and browser workflows.

Prepare responsive image widths

Calculate the matching height for each fixed responsive width before generating image variants.

Validate an exact delivery size

Resolve the requested output box for an advertising slot, marketplace listing, or screen.

Build resize commands

Turn source metadata and a requested side into integer dimensions for an image-processing pipeline.

What happens if I provide only a target width?

The height is calculated from the original aspect ratio and rounded to the nearest whole pixel.

What happens if I provide only a target height?

The width is calculated from the original aspect ratio and rounded to the nearest whole pixel.

Can I provide both target dimensions?

Yes. Both values are returned exactly, even if their ratio differs from the original image ratio.

Does this resize or upload my image?

No. It performs dimension arithmetic only and never receives, decodes, stores, or modifies image data.

What does an API request cost?

Each API request costs $0.002.

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/resize-to-dimensions

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/resize-to-dimensions \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"width":1920,"height":1080,"target_width":1280}'
{
  "width": 1920,
  "height": 1080,
  "target_width": 1280
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "image.resize_to_dimensions",
  "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 →