Compute Meta Ad Image Crops
meta_ads_compute_image_cropsCompute image crop coordinates for ad creative formats. Returns the largest centered region matching each requested aspect ratio, ready for ad creation.
Instructions
Compute image_crops coordinates for a source image. For each requested key, returns the largest centered region that fits the source while matching that key's aspect ratio (equivalent to Meta's "Original" crop — no content cut beyond the ratio).
Valid keys (Meta accepts only these 6): 100x100 — 1:1 square (Feed, Marketplace) 100x72 — ~1.39:1 horizontal (Marketplace) 400x500 — 4:5 portrait (Feed mobile, Stories fallback) 400x150 — ~2.67:1 banner (Audience Network) 600x360 — ~1.67:1 horizontal (Right column) 90x160 — 9:16 portrait (Stories)
Pass the returned image_crops dict to meta_ads_create_ad_creative.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_width | Yes | ||
| image_height | Yes | ||
| crop_keys | No |