Crop an image to a target aspect ratio.
Trims an image so it fits a desired aspect ratio. You can provide a ratio like `16:9` or `1.333` and optionally choose a focal point (`top`, `bottom`, `left`, `right`, or `center`). The service crops the necessary width/height and returns the trimmed image.
/media/aspect-ratio-cropVisual example


Sample request
GET https://api.dataczar.com/media/aspect-ratio-crop?url=https://images.unsplash.com/photo-1498050108023-c5249f4df085?auto=format&fit=crop&w=960&q=80&ratio=4:3&focus=center-top&ak=demoWhere this helper shines
Crop an image to a target aspect ratio. keeps media helpers on autopilot. Use it whenever you need to crop an image to a target aspect ratio without pausing a sprint or asking design/dev to jump in.
- Trigger this helper whenever you need to crop an image to a target aspect ratio without waiting on a full deploy.
- Drop it into automations (Zapier, Make, workers) to crop an image to a target aspect ratio as part of your workflow.
- Share the GET URL so support and success can crop an image to a target aspect ratio safely using their Dataczar API key.
Copy & ship snippets
GET
Instant link
GET https://api.dataczar.app/media/aspect-ratio-crop?url=https%3A%2F%2Fexample.com%2Fsample.png&ratio=1%3A1&focus=center&format=png&ak=demoOpen directly in any browser, webhook, or low-code workflow.
curl
curl GET
curl "https://api.dataczar.app/media/aspect-ratio-crop?url=https%3A%2F%2Fexample.com%2Fsample.png&ratio=1%3A1&focus=center&format=png&ak=demo"Swap ak=demo with your Dataczar API key.
curl
curl POST
curl -X POST "https://api.dataczar.app/media/aspect-ratio-crop?ak=demo" \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/sample.png",
"ratio": "sample_ratio",
"focus": "sample_focus",
"format": "png",
"dryrun": true
}'Send JSON payloads from back-end jobs, queues, or workers.
Parameters
Query Parameters
| Name | Type | Description |
|---|---|---|
| url | string | HTTPS URL for the source image. |
| ratio | string | Aspect ratio expressed as `width:height` or decimal (e.g., `16:9`, `1.777`). |
| focus | string | Where to anchor the crop. Accepts combinations like `top`, `bottom`, `left`, `right`, `center`. |
| format | string | Return format (`png`, `jpg`, etc.). |
| dryrun | boolean | If present, returns metadata instead of the image. |
All helper calls accept your Dataczar key via the ak query parameter. Need one? Create or copy a key on Dataczar Connect and drop it into each request.
Responses
Status 200
Image returned in the requested format with the new aspect ratio.
"Binary image data."Examples
Request
"GET /img/aspect-ratio-crop?url=https://example.com/img.jpg&ratio=16:9&focus=center-top&ak=demo"Response
"Binary image with 16:9 aspect ratio."Test Contracts
[
{
"name": "basic_aspect_crop",
"method": "POST",
"body": {
"url": "https://example.com/img.jpg",
"ratio": "4:3"
},
"expect_status": 200
}
]Grab your Dataczar API key
Every helper runs with the same simple API key. Sign in (or create a free Dataczar account) at Dataczar Connect to issue keys in seconds, then drop the key into any `ak=` parameter and start shipping.
Tip: reuse the same key across these helpers, or rotate keys per project from the Connect dashboard.