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

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

Query parameters

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.