Skip to main content

Calculate crop API

Calculate the crop box that fits an image to a social media size.

  • Endpoint: POST https://postboost.co/app/api/tools/social-media-image-sizes/crop (operationId calculateCrop)
  • Web tool: postboost.co/tools/social-media-image-sizes
  • Token: optional (limits)
  • MCP: tool calculate-crop on https://postboost.co/mcp/tools

Request​

FieldTypeDefaultDescription
widthintegerSource image width in pixels.
heightintegerSource image height in pixels.
networkstringNetwork key from getImageSizes (network_key), e.g. instagram. With format, picks the target size.
formatstringFormat key from getImageSizes (format_key), e.g. feed-square.
target_widthintegerTarget width in pixels, instead of network + format.
target_heightintegerTarget height in pixels, instead of network + format.
fitstring: cover, contain"cover"cover crops to fill the target; contain keeps the whole image and centres it.

Call it​

curl -X POST https://postboost.co/app/api/tools/social-media-image-sizes/crop \
-H 'Content-Type: application/json' \
-d '{"width":4000,"height":3000,"network":"instagram","format":"feed-square"}'

With a token, send Authorization: Bearer YOUR_API_TOKEN as a default header (how, per SDK).

Response​

{
"crop": {
"x": 500,
"y": 0,
"width": 3000,
"height": 3000
},
"output": {
"width": 1080,
"height": 1080
},
"image": {
"x": 0,
"y": 0,
"width": 1080,
"height": 1080
},
"scale": 0.36,
"upscaled": false
}

With MCP​

Connect https://postboost.co/mcp/tools (setup) and ask, for example: Calculate the crop box that fits an image to a social media size with the PostBoost calculate-crop tool.

Errors​

StatusWhen
401The Authorization header holds an invalid token. Leave it out to call as a guest.
413The JSON body is larger than 128 KB.
422A field is invalid; the body lists the errors per field.
429A limit is reached; see limits.