Image Border Trimmer
Auto-trim whitespace or solid-colour borders from an image
/v1/image/trim
curl "https://image.toolkitapi.io/v1/image/trim?url=https://toolkitapi.io/static/samples/sample-image.png&tolerance=15"
import httpx
resp = httpx.get(
"https://image.toolkitapi.io/v1/image/trim?url=https://toolkitapi.io/static/samples/sample-image.png&tolerance=15",
)
print(resp.json())
const resp = await fetch("https://image.toolkitapi.io/v1/image/trim?url=https://toolkitapi.io/static/samples/sample-image.png&tolerance=15", {
});
const data = await resp.json();
console.log(data);
# See curl example
{
"image": "iVBORw0KGgoAAAANSUhEUg...(base64 data)...",
"format": "png",
"original_size": {"width": 1200, "height": 1200},
"new_size": {"width": 980, "height": 950},
"trimmed": true
}
Try It Live
Description
How to Use
1. Provide the source image via the `url` query parameter.
2. Set `tolerance` (0–255) to control how strictly the border colour is matched. Higher values trim more aggressively.
3. The trimmed image is returned along with original and new dimensions.
4. Check the `trimmed` field — if false, no border was detected.
About This Tool
Use the Image Border Trimmer to automatically detect and remove uniform borders around an image. It compares each pixel to the top-left corner pixel colour and trims any matching border area, with a configurable colour tolerance.
This is particularly useful for product photography (removing white backgrounds), scanned documents (removing scanner borders), and cleaning up screenshots or exported images with unnecessary padding.
Why Use This Tool
- Product photography — Remove white borders from product images for clean catalog layouts
- Scanned documents — Trim scanner borders from digitised pages
- Screenshot cleanup — Remove desktop backgrounds from window screenshots
- Batch processing — Normalize image boundaries across an image set
- SVG-to-raster cleanup — Trim excess canvas from exported raster images
Frequently Asked Questions
How is the border colour determined?
What tolerance should I use?
What happens if the entire image is one colour?
Start using Image Border Trimmer now
Get your free API key and make your first request in under a minute.