compute_image_crops
Generate image crop coordinates for Meta ad creatives. Input image width and height (and optional crop keys) to receive a ready-to-use image_crops dict for various placements.
Instructions
Compute image_crops coordinates for a source image of the given dimensions.
Returns the image_crops dict ready to pass directly to create_ad_creative
or bulk_create_ad_creatives. For each crop key the result is the largest
centered region that fits within the source image while matching the key's
aspect ratio — equivalent to "Original" crop (no content is cut off beyond
what the ratio requires).
Args:
image_width: Width of the source image in pixels (e.g. 1080).
image_height: Height of the source image in pixels (e.g. 1080).
crop_keys: Optional list of specific crop keys to compute. Defaults to
all 6 keys accepted by Meta's API:
"100x100" — 1:1 square (Feed, Marketplace, Search)
"100x72" — ~1.39:1 horizontal (Marketplace, some placements)
"400x500" — 4:5 portrait (Feed on mobile, Stories fallback)
"400x150" — ~2.67:1 wide banner (Audience Network)
"600x360" — ~1.67:1 horizontal (Right column, some placements)
"90x160" — 9:16 tall portrait (Stories)
Returns:
JSON with the image_crops dict (ready for copy-paste into create_ad_creative),
plus validation notes for any invalid keys requested.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_width | Yes | ||
| image_height | Yes | ||
| crop_keys | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |