Dataczar
Browse helpers

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-crop

Visual example

Before
Before
After
After

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=demo

Where 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=demo

Open 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

NameTypeDescription
urlstringHTTPS URL for the source image.
ratiostringAspect ratio expressed as `width:height` or decimal (e.g., `16:9`, `1.777`).
focusstringWhere to anchor the crop. Accepts combinations like `top`, `bottom`, `left`, `right`, `center`.
formatstringReturn format (`png`, `jpg`, etc.).
dryrunbooleanIf 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
  }
]

File uploads (multipart form-data)

Attach PDFs or images as multipart fields. We'll fill in the field names for you.

Files
file — Source image

Query parameters

Body parameters

We'll send these as JSON for POST/PUT/PATCH requests and as query params for GET.

Equivalent curl

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.