---
title: Crop Images API
slug: crop-image
url: https://apyhub.com/apyhub/service/crop-image
provider: ApyHub
categories: [Media Kit]
tags: [image-crop, crop, image-editing, image-processing]
auth: api_key
version: 1.0.0
service_type: sync
endpoints: 4
atoms: 30
mcp: true
alias: image-processor-crop
---

# Crop Images API

Image crop API that trims JPEG, PNG, WebP, GIF, TIFF and BMP files by exact size or by edge insets in pixels or percent, from a URL or upload.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/apyhub/crop-image/url/link` | What it does Crops an image fetched from a URL and returns a signed URL for the cropped result. Use… | 30 |
| POST | `https://api.eu.apyhub.com/apyhub/crop-image/multi-part/download` | What it does Crops an uploaded image and returns the resulting file as binary data. You can crop by… | 30 |
| POST | `https://api.eu.apyhub.com/apyhub/crop-image/multi-part/link` | What it does Crops an uploaded raster image and returns a time-limited pre-signed URL to the stored… | 30 |
| POST | `https://api.eu.apyhub.com/apyhub/crop-image/url/download` | What it does Crops an image fetched from a URL and returns the resulting file as binary data. The r… | 30 |

## Endpoint reference

### Crop image (fetch by URL, return signed URL)

`POST https://api.eu.apyhub.com/apyhub/crop-image/url/link` · 30 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `top` | body | string | no | Top edge inset — e.g. 10px or 10%. Required with the other three margin fields in margin mode. Example: `10px`. |
| `url` | body | string (uri) | no | Image URL for dimension mode. Set this field to use width×height box crop from the top-left origin. Do not combine with image_url. Example: `https://assets.apyhub.com/samples/sample.png`. |
| `left` | body | string | no | Left edge inset — e.g. 5px or 5%. Required with the other three margin fields in margin mode. Example: `5%`. |
| `right` | body | string | no | Right edge inset — e.g. 5px or 5%. Required with the other three margin fields in margin mode. Example: `5%`. |
| `bottom` | body | string | no | Bottom edge inset — e.g. 10px or 10%. Required with the other three margin fields in margin mode. Example: `10px`. |
| `image_url` | body | string (uri) | no | Image URL for margin mode. Set this field to use edge-inset cropping with top, bottom, left, and right. Do not combine with url. Example: `https://assets.apyhub.com/samples/sample.png`. |
| `width` | query | integer | no | Example: `400`. |
| `height` | query | integer | no | Example: `300`. |
| `output` | query | string | no | Example: `cropped-result`. |
| `preserve_format` | query | boolean | no | Default: `false`. Example: `true`. |

#### Quickstart

Crop an image from a URL using the dimension mode, with the image URL in the JSON body and the crop size in query parameters.

```bash
curl -X POST "https://api.eu.apyhub.com/apyhub/crop-image/url/link?width=400&height=300&output=cropped-result" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.png"}'
```

#### What you'll get back

Returns a JSON object with a `data` string field containing a time-limited pre-signed URL to the cropped image.

```json
{
  "data": "https://storage.example.com/crop/cropped-result.png?X-Amz-Signature=def456&X-Amz-Expires=3600"
}
```

### Crop image (multipart upload, download file)

`POST https://api.eu.apyhub.com/apyhub/crop-image/multi-part/download` · 30 atoms · accepts `multipart/form-data` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `top` | body | string | no | Top edge inset (e.g. 20px or 10%). Required together with bottom, left, and right for margin mode. Omit all four to use dimension mode instead. Example: `20px`. |
| `left` | body | string | no | Left edge inset (e.g. 15px or 5%). See top. Example: `15px`. |
| `image` | body | string (binary) | yes | Raster image file to crop. Supported formats — JPEG, PNG, WebP, GIF, TIFF, BMP. Example: `sample.png`. |
| `right` | body | string | no | Right edge inset (e.g. 15px or 5%). See top. Example: `15px`. |
| `bottom` | body | string | no | Bottom edge inset (e.g. 20px or 10%). See top. Example: `20px`. |
| `width` | query | integer | no | Example: `400`. |
| `height` | query | integer | no | Example: `300`. |
| `output` | query | string | no | Example: `cropped-result`. |
| `preserve_format` | query | boolean | no | Default: `false`. Example: `true`. |

#### Quickstart

Crop an uploaded image and return the cropped file.

```bash
curl -X POST "https://api.eu.apyhub.com/apyhub/crop-image/multi-part/download" \
  -H "apy-token: $APY_TOKEN" \
  -F "image=@/path/to/sample.png"
```

#### What you'll get back

Returns a binary file response (`string` with `format: binary`), not a JSON object.

```binary
<cropped image bytes>
```

### Crop image (multipart upload, return signed URL)

`POST https://api.eu.apyhub.com/apyhub/crop-image/multi-part/link` · 30 atoms · accepts `multipart/form-data` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `top` | body | string | no | Top edge inset (e.g. 20px or 10%). See margin mode in endpoint description. Example: `20px`. |
| `left` | body | string | no | Left edge inset (e.g. 15px or 5%). Example: `15px`. |
| `image` | body | string (binary) | yes | Raster image file to crop. Supported formats — JPEG, PNG, WebP, GIF, TIFF, BMP. Example: `sample.png`. |
| `right` | body | string | no | Right edge inset (e.g. 15px or 5%). Example: `15px`. |
| `bottom` | body | string | no | Bottom edge inset (e.g. 20px or 10%). Example: `20px`. |
| `width` | query | integer | no | Example: `400`. |
| `height` | query | integer | no | Example: `300`. |
| `output` | query | string | no | Example: `cropped-result`. |
| `preserve_format` | query | boolean | no | Default: `false`. Example: `true`. |

#### Quickstart

Crop an image from a public link by sending the image URL along with the required crop file field.

```bash
curl -X POST "https://api.eu.apyhub.com/apyhub/crop-image/multi-part/link?width=400&height=300&output=cropped-result&preserve_format=true" \
  -H "apy-token: $APY_TOKEN" \
  -F "image=@/path/to/sample.png"
```

#### What you'll get back

Returns a JSON object with a `data` string field containing a time-limited pre-signed URL to the cropped image.

```json
{
  "data": "https://storage.example.com/crop/cropped-result.png?X-Amz-Signature=abc123&X-Amz-Expires=3600"
}
```

### Crop image (fetch by URL, download file)

`POST https://api.eu.apyhub.com/apyhub/crop-image/url/download` · 30 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `top` | body | string | no | Top edge inset — e.g. 10px or 10%. Required with the other three margin fields in margin mode. Example: `10px`. |
| `url` | body | string (uri) | no | Image URL for dimension mode. Set this field to use width×height box crop from the top-left origin. Do not combine with image_url. Example: `https://assets.apyhub.com/samples/sample.png`. |
| `left` | body | string | no | Left edge inset — e.g. 5px or 5%. Required with the other three margin fields in margin mode. Example: `5%`. |
| `right` | body | string | no | Right edge inset — e.g. 5px or 5%. Required with the other three margin fields in margin mode. Example: `5%`. |
| `bottom` | body | string | no | Bottom edge inset — e.g. 10px or 10%. Required with the other three margin fields in margin mode. Example: `10px`. |
| `image_url` | body | string (uri) | no | Image URL for margin mode. Set this field to use edge-inset cropping with top, bottom, left, and right. Do not combine with url. Example: `https://assets.apyhub.com/samples/sample.png`. |
| `width` | query | integer | no | Example: `400`. |
| `height` | query | integer | no | Example: `300`. |
| `output` | query | string | no | Example: `cropped-result`. |
| `preserve_format` | query | boolean | no | Default: `false`. Example: `true`. |

#### Quickstart

Crop an image from a URL by sending the source image plus the required width and height query parameters.

```bash
curl -X POST "https://api.eu.apyhub.com/apyhub/crop-image/url/download?width=400&height=300" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.png"}'
```

#### What you'll get back

Returns the cropped image as binary data.

## About

## What it does

The image crop API trims raster images to the frame you need. Send a public image URL or upload the file (up to 100 MB per request), and get the cropped image back as a file download or as a time-limited signed URL. It supports JPEG, PNG, WebP, GIF, TIFF and BMP.

There are two ways to define the crop. In dimension mode, set `width` and `height` to cut a box of that size from the top-left corner. In margin mode, set `top`, `bottom`, `left` and `right` insets in pixels (`10px`) or percent (`5%`) to trim each edge. Percent insets work well when a batch holds images of different sizes. Set `preserve_format` to `true` to keep the original format.

Use the image crop API to cut product shots to a consistent frame, trim toolbars and borders from screenshots, remove letterboxing from video stills, and prepare banner and social assets at fixed sizes. Profile photo uploads can be cropped server-side so every avatar matches your layout.

When the subject isn't in a predictable place, the [Smart Crop API](https://apyhub.com/dosvak/service/smart-crop) crops around detected faces instead. To fit a crop into exact display dimensions, follow it with the [Image Resize API](https://apyhub.com/apyhub/service/resize-image), then reduce file size with the [Image Compression API](https://apyhub.com/apyhub/service/compress-images).

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/apyhub/service/crop-image
