Calculate aspect ratio and crop/pad plan
calculate_aspect_ratioReduce any pixel size to its simplest aspect ratio (1920x1080 is 16:9) and the nearest even size an H.264 encoder accepts, and, given a target ratio, solve the missing width or height and return the centre-crop and letterbox/pillarbox plans with the px trimmed or added per edge. Use this for arbitrary sizes and ratios (cinema 2.39:1, a client's 4:5); when the target is a named platform placement, use get_social_media_placement with sourceWidth/sourceHeight instead, which picks the right ratio for you. Errors on a non-integer or out-of-range size, or on only one of targetRatioW/targetRatioH.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"width": "<width>",
"height": "<height>"
},
"name": "calculate_aspect_ratio"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| width | Yes | Frame width in px. | |
| height | Yes | Frame height in px. | |
| targetRatioH | No | Height term of the target ratio, e.g. 16 for 9:16. Requires targetRatioW. | |
| targetRatioW | No | Width term of the ratio to crop or pad to, e.g. 9 for 9:16 or 2.39 for 2.39:1. Requires targetRatioH. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | ||
| ratio | Yes | ||
| padPlan | Yes | ||
| cropPlan | Yes | ||
| targetRatio | Yes | ||
| formattedRatio | Yes | ||
| evenEncoderSize | Yes | ||
| referenceToolUrl | Yes | ||
| solvedHeightForWidth | Yes | ||
| solvedWidthForHeight | Yes |