Crop Image
Image → Crop Image
The Crop Image API crops an image by border or rectangle. You send the image as Base64 (docContent), docName, CropType (Border or Rectangle), and for Border: LeftBorder, RightBorder, TopBorder, BottomBorder; for Rectangle: UpperLeftX, UpperLeftY, Width, Height; optionally async. The API returns the cropped image. Use the tester below to try it; more details are in the sections that follow.
Try the Crop Image API
Endpoint: POST /api/v2/CropImage · Required: api-key, docContent, docName, CropType
Use the form below to send your API key and image (Base64). Choose Border or Rectangle and set dimensions; the response is the cropped image. No code required—fill the fields and click Send request.
Overview, parameters, and use cases
- Overview
- Parameters
- Use cases
What is Crop Image?
This endpoint crops an image. You provide the image (Base64), docName, and CropType: Border (LeftBorder, RightBorder, TopBorder, BottomBorder in pixels) or Rectangle (UpperLeftX, UpperLeftY, Width, Height in pixels). The API returns the cropped image.
Key features
- Border – Crop by specifying left, right, top, and bottom border values in pixels.
- Rectangle – Crop by specifying upper-left (X, Y) and width/height in pixels.
- Formats – Supported: JPG, PNG, GIF, BMP, TIFF.
Use when you need to remove borders or extract a region. Combine with Resize Image or Compress Image in a pipeline.
API parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api-key | string | Yes | Your PDF4me API key, Base64 encoded. Get it from the dashboard. |
| docContent | base64 | Yes | Image file content (Base64). Supported: JPG, PNG, GIF, BMP, TIFF. |
| docName | string | Yes | Output image file name. |
| CropType | string | Yes | Border or Rectangle. |
| LeftBorder, RightBorder, TopBorder, BottomBorder | string | No | Border crop values in pixels (for Border). |
| UpperLeftX, UpperLeftY, Width, Height | integer | No | Rectangle crop (for Rectangle). |
| async | boolean | No | Enable asynchronous processing. |
When to use Crop Image
- Remove borders – Crop white or black borders from scans or screenshots.
- Extract region – Select a region by coordinates for thumbnails or analysis.
- Pipelines – Crop before Resize Image or Compress Image.
For request/response schemas and code samples, see Crop Image in the PDF4me API docs.
Prerequisites
Before using this endpoint, make sure you have:
- A valid PDF4me API key (Get your API Key)
- An image file (JPG, PNG, GIF, BMP, TIFF) in Base64 format
Response Format
The API returns a cropped image file with the specified crop area applied.