ForHosting KIT · Images

Crop an image

Resizing changes how big an image is; cropping changes what's actually in the frame. When a photo has the right subject but the wrong shape for the space you need to fill, this endpoint cuts it down to exact coordinates or a target aspect ratio, without touching anything outside the crop box.

● StablePer request + per image$0.002
Use it from WebAPIEmailApp soonTelegram soon

Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.

Cropping solves a different problem than resizing

It's tempting to treat cropping and resizing as the same operation, but they answer different questions. Resizing asks how big should this whole image be; cropping asks which part of this image do I actually want. A wide landscape photo squeezed into a square resize just gets distorted, but the same photo cropped to a square keeps its subject intact and simply discards the parts of the frame you don't need — which is almost always what a design actually calls for when a photo doesn't match its slot.

Two ways to tell it what to keep

You can specify an exact crop in pixel coordinates, giving the top-left corner along with width and height, which is the right choice when you already know precisely what region matters, for example a face detected by an upstream process or a logo in a fixed position. Or you can specify a target aspect ratio, like 1:1 or 16:9, and let the task center the crop automatically, which is the faster path when you just need a shape to fit a layout and don't need pixel-level control over the framing.

A quick word on why aspect ratio still matters

Aspect ratio has been a constraint on visual media since long before digital cameras existed, from the fixed proportions of film stock to the different ratios of television and cinema, and every one of those ratios exists because a specific display technology demanded it. Today's constraint is the same idea in a new form: a card component, a hero banner, and a social post thumbnail each expect a specific ratio, and a single source photo almost never arrives already shaped to fit all three.

Fitting into a design or publishing pipeline

Cropping is typically the last step before an image goes live, run after any resizing so the final output is both the right shape and the right file size for its destination. Pair it with a resize call when you need both operations, first cropping to the correct aspect ratio, then resizing to the exact final dimensions, or run crop alone when the source image is already close to the size you need and only the framing is wrong. Because it runs asynchronously, it drops cleanly into content pipelines that process user uploads or CMS assets without blocking the request that triggered it.

Social media thumbnail preparation

A publishing tool crops an article's featured image to the square and landscape ratios each social platform expects, generating platform-ready thumbnails from one source photo.

Product photo framing on a marketplace

A marketplace crops supplier photos to a consistent square framing so every product tile lines up visually, regardless of the original photo's shape.

Face-centered avatar cropping

A user-profile system uses coordinates from an upstream face-detection step to crop uploaded photos so the subject's face stays centered in the avatar.

Editorial hero image adjustment

A newsroom CMS crops a wire photo to the exact aspect ratio the homepage's hero slot requires, preserving the parts of the image the editor selected.

How do I crop an image with exact coordinates?

Send a POST to /image/crop with the source image and the pixel coordinates of the crop box, top-left position plus width and height, and you'll get back exactly that region.

Can I crop to an aspect ratio instead of exact coordinates?

Yes, specify a target ratio like 1:1 or 16:9 and the task centers the crop automatically, which is faster when you don't need pixel-level control.

What's the difference between crop and resize?

Resize changes the overall dimensions of the whole image and can distort its proportions; crop cuts out a specific region and discards the rest, keeping everything inside the crop box unchanged.

Is there a free tier for the image crop api?

There's no free tier — free tiers get abused and slow everyone down. Access runs on a prepaid ForHosting KIT balance: top up from $10.00 (it never expires) and each request is charged at its published price, so a call with no balance returns HTTP 402. No subscription, no tokens, no invented credits, and a failed task is never charged.

How much does cropping an image cost?

$0.002 per request plus $0.005 per image, charged only when the crop actually completes successfully.

What happens if my crop coordinates go outside the image bounds?

The task validates the crop box against the source image and returns a clear error if it doesn't fit, rather than silently producing a distorted or padded result.

Can I crop and resize in the same workflow?

Yes, the common pattern is cropping first to fix the aspect ratio, then resizing to the exact final dimensions, using this endpoint and the resize endpoint together.

How do I retrieve the cropped image?

Via a signed webhook, recommended for automated pipelines, or through a signed link valid for 24 hours after the task finishes.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/image/crop

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.

curl -X POST https://api.kit.forhosting.com/image/crop \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image":"https://ejemplo.com/imagen.jpg"}'
{
  "image": "https://ejemplo.com/imagen.jpg"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "image.crop",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002
Per image$0.005

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb15
max_megapixels12
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →