Navigation
POST image

crop

1 credit

Crop image to coordinates or center-crop to an aspect ratio

Endpoint

POST /api/v1/tools/image/crop

Body Parameters

top integer | null optional default: null
left integer | null optional default: null
right integer | null optional default: null
bottom integer | null optional default: null
format string optional default: "PNG"
aspect_ratio string | null optional default: null
image_base64 string required

Example

input Request
{
    "top": 0,
    "left": 0,
    "right": 1,
    "bottom": 1,
    "image_base64": "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFElEQVR4nGP8z8Dwn4GBgYGJAQoAHxcCAk+Uzr4AAAAASUVORK5CYII="
}
output Response
{
    "width": 1,
    "format": "PNG",
    "height": 1,
    "image_base64": "..."
}

Response Format

HTTP/1.1 200 OK SUCCESS
{
  "success": true,
  "data": {
    "width": 1,
    "format": "PNG",
    "height": 1,
    "image_base64": "..."
},
  "meta": {
    "tool": "crop",
    "credits_consumed": 1
  }
}
HTTP/1.1 422 Unprocessable Entity ERROR
{
  "success": false,
  "data": null,
  "error": {
    "code": "validation_error",
    "message": "The given data was invalid."
  }
}

Sign in to try this tool directly from the docs.

Code Examples
Request Example
lightbulb Developer Tip

Credits are deducted before execution. If the upstream tool fails, credits are automatically refunded to your account.