Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Aspect Ratio Calculator API

Simplify width × height to an aspect ratio (1920×1080 → 16:9, with the nearest common preset), or resize to a ratio by solving the missing width or height.

POST /api/v1/tools/aspect-ratio-calculatorMCP aspect_ratio_calculatorDesign & Colour

Find the aspect ratio of any width and height, simplify ratios like 1920×1080 to 16:9, and work out a missing width or height. Includes common presets.

Input

Send these as a JSON object. Unknown fields are rejected.

mode
simplify: reduce width and height to a ratio. solve: given ratio and one of width or height, compute the other. (string, one of simplify, solve, default "simplify")
width
Width in any unit (pixels, cm…), greater than 0. Required for simplify; for solve, give width or height, not both. (number, 0 to …)
height
Height in the same unit, greater than 0. Required for simplify; for solve, give width or height, not both. (number, 0 to …)
ratio
For solve: the target ratio, e.g. "16:9", "4/3", "21x9" or a decimal like "2.39". (string, up to 40 characters)
curl https://pithlab.com/api/v1/tools/aspect-ratio-calculator \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"mode":"simplify","width":1920,"height":1080}'
Example response
{
  "ok": true,
  "result": {
    "ratio": "16:9",
    "w": 16,
    "h": 9,
    "decimal": 1.7777777777777777,
    "nearestPreset": {
      "label": "16:9",
      "use": "HD video, YouTube, most monitors and TVs"
    }
  }
}