Calculate aspect ratio and crop/pad plan
calculate_aspect_ratioReduce any pixel size to its simplest aspect ratio, round dimensions up to even or codec-block multiples, and get centre-crop plus letterbox/pillarbox plans for a target ratio.
Instructions
Reduce any pixel size to its simplest aspect ratio (1920x1080 is 16:9), round it up to an even or codec-block multiple, and, given a target ratio, return the centre-crop and letterbox/pillarbox plans with the px removed 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. | |
| blockSize | No | Round dimensions up to a multiple of this: 2 for H.264 4:2:0, 16 for macroblock-aligned. Default 2. | |
| 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 | ||
| blockSize | Yes | ||
| targetRatio | Yes | ||
| alignedToBlock | Yes | ||
| formattedRatio | Yes | ||
| referenceToolUrl | Yes |