Image Crop
Crop an image by coordinates, center-gravity, or smart square
/v1/image/crop
curl "https://image.toolkitapi.io/v1/image/crop?url=https://toolkitapi.io/static/samples/sample-image.png&mode=coordinates&x=100&y=50&width=800&height=600"
import httpx
resp = httpx.get(
"https://image.toolkitapi.io/v1/image/crop?url=https://toolkitapi.io/static/samples/sample-image.png&mode=coordinates&x=100&y=50&width=800&height=600",
)
print(resp.json())
const resp = await fetch("https://image.toolkitapi.io/v1/image/crop?url=https://toolkitapi.io/static/samples/sample-image.png&mode=coordinates&x=100&y=50&width=800&height=600", {
});
const data = await resp.json();
console.log(data);
# See curl example
{
"image": "/9j/4AAQSkZJRgABAQ...(base64 data)...",
"format": "png",
"original_size": {"width": 1920, "height": 1080},
"crop_box": {"x": 100, "y": 50, "width": 800, "height": 600},
"new_size": {"width": 800, "height": 600}
}
Try It Live
Description
How to Use
1. Provide the source image via the `url` query parameter.
2. Choose a `mode`: `coordinates` (provide x, y, width, height), `smart` (center crop), or `square` (largest centered square).
3. For `coordinates` mode, specify `x`, `y`, `width`, and `height` in pixels.
4. The response includes the original size, crop box used, and the new dimensions.
About This Tool
Use the Image Crop endpoint to extract a rectangular region from any image. Three crop modes are available: `coordinates` for explicit pixel-based cropping, `smart` for center-gravity cropping to the smaller dimension, and `square` for extracting the largest centered square.
The smart and square modes are great for generating consistent thumbnails and profile pictures without manual coordinate calculation.
Why Use This Tool
- Profile pictures — Crop to square for avatar generation
- Thumbnail creation — Extract consistent regions from variable-sized images
- Region extraction — Isolate a specific area of interest from a larger image
- Aspect ratio conversion — Crop to match specific aspect ratios for social media
- Product focus — Crop to highlight a product within a lifestyle photograph
Frequently Asked Questions
What is the difference between smart and square modes?
What happens if crop coordinates exceed image bounds?
Can I crop to a specific aspect ratio?
Start using Image Crop now
Get your free API key and make your first request in under a minute.