Calculate image aspect ratio from width and height
The image aspect ratio calculator turns an image's pixel width and height into the smallest equivalent whole-number ratio.
Run — free
Enter dimensions such as 1920 by 1080 and receive 16:9, together with the reduced width and height components used to form it. This is useful when preparing responsive layouts, checking exports, documenting media requirements, or comparing images whose pixel sizes differ but whose shapes match. The calculation is deterministic, uses no network service, and rejects zero dimensions because an image with no width or height has no defined aspect ratio.
Enter the image dimensions accurately
Provide the image width and height as whole pixel counts. You can usually find these values in an operating system's file information panel, an image editor's document properties, a digital asset manager, or metadata returned by an upload pipeline. Keep the orientation exactly as it appears in the source: a landscape image might be 1920 pixels wide and 1080 pixels high, while its portrait rotation would be 1080 pixels wide and 1920 pixels high. Those pairs describe different shapes and therefore produce 16:9 and 9:16 respectively. The calculator accepts positive safe integers because pixel dimensions describe discrete columns and rows, not fractions. Do not add units, multiplication signs, commas, or labels to the numeric fields. Width and height must both be greater than zero. If either value is zero, the request returns an invalid input error instead of inventing a ratio, since division and geometric proportions are not meaningful for an image with a missing dimension.
Understand how simplification works
The calculator finds the greatest common divisor of the two dimensions with the Euclidean algorithm. It then divides both width and height by that same divisor, preserving the image's proportions while reducing the pair to the smallest possible positive integers. For a 1920 by 1080 image, the greatest common divisor is 120, so dividing both numbers by 120 produces 16 and 9. The result is displayed as 16:9 and is also returned in separate ratio_width and ratio_height fields for automation. No table of familiar formats is involved, so unusual dimensions are handled just as reliably as standard video sizes. For example, 1500 by 1000 simplifies to 3:2, while 1024 by 1024 simplifies to 1:1. If the dimensions share no divisor larger than one, the original pair is already in simplest form. The original width and height are included in the response so applications can retain a clear audit trail of the values that produced the ratio.
Use the result in design and automation
Use the simplified ratio to compare image shapes independently of resolution. A 320 by 180 thumbnail, a 1280 by 720 preview, and a 3840 by 2160 master all reduce to 16:9, even though their pixel counts and storage requirements differ substantially. In responsive CSS, the returned value can inform an aspect-ratio declaration or a placeholder that reserves the right amount of space before an image loads. In editorial systems, it can validate whether uploads conform to a required shape without demanding one exact resolution. In production pipelines, save the two numeric ratio components when structured comparisons are easier than parsing a formatted string, and use aspect_ratio when a human-readable label is preferable. Remember that matching ratios do not imply matching image quality, file size, crop, color profile, or orientation metadata. This capability only describes the mathematical relationship between width and height. Browser use is free, while automated API requests begin at $0.002 per item.
What you can do with it
Check an image export
Confirm that exported pixel dimensions preserve the intended shape before publishing an asset.
Build responsive placeholders
Derive a reduced ratio for layout space that matches an image before the file finishes loading.
Validate media uploads
Compare normalized ratios across differently sized uploads without requiring one fixed resolution.
FAQ
What does 1920 by 1080 simplify to?
It simplifies to 16:9 because both dimensions can be divided by 120.
What happens if width or height is zero?
The calculation returns an invalid input error because a zero dimension does not define an image aspect ratio.
Can I use fractional dimensions?
No. Image dimensions must be positive whole pixel counts represented as safe integers.
Does the calculator resize or crop my image?
No. It only computes the simplified relationship between the supplied width and height.
How much does the API cost?
Each API request starts at $0.002 per item. The browser calculator is free to use.
For developers — API 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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/image/aspect-ratio-calc \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"width":1920,"height":1080}'const res = await fetch("https://api.kit.forhosting.com/image/aspect-ratio-calc", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"width": 1920,
"height": 1080
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/image/aspect-ratio-calc",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"width": 1920,
"height": 1080
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/image/aspect-ratio-calc", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"width":1920,"height":1080}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"width":1920,"height":1080}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/image/aspect-ratio-calc", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"width": 1920,
"height": 1080
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "image.aspect_ratio_calc",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 15 |
max_megapixels | 12 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |