Aspect Ratio Calculator API - simplify ratios, lock-ratio resize, crop/letterbox math & batch
aspect_ratio_calculatorCalculate simplified aspect ratios (GCD), decimal ratios, megapixels, orientation, and nearest standard format (16:9, 9:16, 4:3, 21:9, 4:5, 1:1). Compute locked-ratio resize dimensions or exact crop (cover) and letterbox/pillarbox (contain) pixel math for any target frame or preset. Single or batch up to 500 items. 0 AI, pure stdlib deterministic, < 5 ms, nothing stored. Free: 5 calls/day per IP. Paid: Radar API key (from €15/mo at https://radarbg.com/pricing#starter via X-API-Key) or $0.001/call via x402 at https://radarbg.com/x402/aspect-ratio-calculator.
Example tool call
This call uses example arguments supplied in the tool’s input schema.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"width": 1920,
"height": 1080,
"targetWidth": 1280
},
"name": "aspect_ratio_calculator"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | No | Source width in pixels (or any unit) | |
| height | No | Source height in pixels (or any unit) | |
| preset | No | Optional target screen preset for crop/letterbox math | none |
| dimensions | No | Optional batch list of 'WxH' strings like ['1920x1080', '1080x1350'] | |
| targetWidth | No | Optional target width (leave targetHeight empty to lock ratio) | |
| targetHeight | No | Optional target height (leave targetWidth empty to lock ratio) |