Aspect ratio calculator

Simplify a width and height to a ratio such as 16:9, and scale to a new width or height.

Input

The original width.
The original height.
A new width, to get the matching height.
A new height, to get the matching width.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/aspect-ratio \
  -H 'Content-Type: application/json' \
  -d '{"input":{"width":1920,"height":1080,"target_width":1280}}'
import json, urllib.request

body = {'input': {'width': 1920, 'height': 1080, 'target_width': 1280}}
request = urllib.request.Request("https://setget.net/v1/tools/aspect-ratio", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/aspect-ratio", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"width":1920,"height":1080,"target_width":1280}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "aspect-ratio",
  "input": {
    "width": 1920,
    "height": 1080,
    "target_width": 1280
  }
}
{
  "input": {
    "width": 1920,
    "height": 1080,
    "target_width": 1280
  }
}

Endpoint: POST /v1/tools/aspect-ratio. Over MCP: run_tool with slug: "aspect-ratio". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
width number yes The original width.
height number yes The original height.
target_width number no A new width, to get the matching height.
target_height number no A new height, to get the matching width.

Examples

Input
{
  "width": 1920,
  "height": 1080,
  "target_width": 1280
}
Result
{
  "ratio": "16:9",
  "ratio_width": 16,
  "ratio_height": 9,
  "decimal": 1.7778,
  "orientation": "landscape",
  "nearest_common": "16:9",
  "target": {
    "width": 1280,
    "height": 720
  }
}

Nearly 16:9

Input
{
  "width": 1366,
  "height": 768
}
Result
{
  "ratio": "683:384",
  "ratio_width": 683,
  "ratio_height": 384,
  "decimal": 1.7786,
  "orientation": "landscape",
  "nearest_common": "16:9",
  "target": null
}

Questions

Why is 1366 x 768 not exactly 16:9?
Because 1366 / 768 is 1.7786, not 1.7778. The exact ratio is 683:384, and "nearest_common" tells you it is closest to 16:9.
Are the target sizes rounded?
To two decimal places. Round to whole pixels yourself if you need to.