# Aspect ratio calculator

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

- Endpoint: `POST https://setget.net/v1/tools/aspect-ratio` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `aspect-ratio`
- Page: https://setget.net/tools/aspect-ratio

## Inputs

- `width` (required, number, range ..1000000000.0): The original width.
- `height` (required, number, range ..1000000000.0): The original height.
- `target_width` (optional, number, range ..1000000000.0): A new width, to get the matching height.
- `target_height` (optional, number, range ..1000000000.0): A new height, to get the matching width.

## Example 1

```json
{"input":{"width":1920,"height":1080,"target_width":1280}}
```

Result:

```json
{"ratio":"16:9","ratio_width":16,"ratio_height":9,"decimal":1.7778,"orientation":"landscape","nearest_common":"16:9","target":{"width":1280,"height":720}}
```

## Example 2: Nearly 16:9

```json
{"input":{"width":1366,"height":768}}
```

Result:

```json
{"ratio":"683:384","ratio_width":683,"ratio_height":384,"decimal":1.7786,"orientation":"landscape","nearest_common":"16:9","target":null}
```

**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.
