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.
GETPOST
/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=demoParameters
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.