---
title: "Reduce a ratio or resolution to lowest terms, name the nearest common ratio, solve the missing dimension and write CSS aspect-ratio."
method: POST
path: "/api/v1/aspect-ratio"
tags: ["Web Tools"]
---

# Reduce a ratio or resolution to lowest terms, name the nearest common ratio, solve the missing dimension and write CSS aspect-ratio.

`POST /api/v1/aspect-ratio`

## Request

- Base URL: `https://programmes.net`
- URL: `https://programmes.net/api/v1/aspect-ratio`
- Auth: none declared

Aspect Ratio Calculator. Operations: `analyze` — Reduce a ratio or size (16:9, 1920x1080, 2.39) and return presets, CSS and whole-pixel sizes. `solve` — Given a ratio and one dimension, compute the other. `fit` — Largest size at this ratio that fits inside (contain) or covers (cover) a box.

## Request body

- union
  - AspectRatioAnalyze: Reduce a ratio or size (16:9, 1920x1080, 2.39) and return presets, CSS and whole-pixel sizes.
    - `operation` 'analyze', required
    - `input` string: A ratio (16:9, 4/3, 1.85:1) or a size (1920x1080).
    - `options` object
  - AspectRatioSolve: Given a ratio and one dimension, compute the other.
    - `operation` 'solve', required
    - `input` string: A ratio or size, e.g. "16:9".
    - `options` object
      - `width` number: Known width (give width or height).
      - `height` number: Known height.
  - AspectRatioFit: Largest size at this ratio that fits inside (contain) or covers (cover) a box.
    - `operation` 'fit', required
    - `input` string: A ratio or size, e.g. "9:16".
    - `options` object, required
      - `boxWidth` number, required: Box width.
      - `boxHeight` number, required: Box height.
      - `mode` 'contain' | 'cover': Like CSS object-fit.

## Response `200`

The operation ran.

- object
  - `ok` unknown, required
  - `tool` 'aspect-ratio', required
  - `operation` 'analyze' | 'solve' | 'fit', required
  - `result` unknown, required

## Other responses

- `400`: The request is not valid (https://programmes.net/api#invalid-request); The tool has no such operation (https://programmes.net/api#unknown-operation)
- `404`: No such tool (https://programmes.net/api#unknown-tool)
- `413`: The request or its input is too large (https://programmes.net/api#content-too-large)
- `415`: The body must be JSON (https://programmes.net/api#unsupported-media-type)
- `422`: An option is missing, of the wrong type or out of range (https://programmes.net/api#invalid-options); This call needs more CPU than one API call may use (https://programmes.net/api#refused); The operation could not process the input (https://programmes.net/api#tool-error)
- `429`: Too many requests (https://programmes.net/api#rate-limited)
- `500`: Internal error (https://programmes.net/api#internal-error)

---

[API](https://skmtc.dev/programmes/apis/programmes-net-api.md) · [All operations](https://skmtc.dev/programmes/apis/programmes-net-api/llms.txt) · [OpenAPI document](https://skmtc.dev/programmes/apis/programmes-net-api/revisions/aa939784a2e6?raw)
