Image auto trim
Scan the four edges for contiguous background (same colour or transparent) and trim the excess away, with adjustable tolerance, reference colour and padding, then export PNG or JPEG.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Images are processed locally in your browser with Canvas and never uploaded.
Blank uses the top-left pixel as the reference colour; you can also set #ffffff explicitly.
RGB distance from 0 to 255; raise it to 16–32 for JPEG noise around white backgrounds.
Pick an image first (PNG / JPEG / WebP / GIF all work).
Result details
Pick an image and the surrounding blank space is trimmed away immediately.
What this tool does
- Remove the white margins around scans, screenshots and exported assets so the subject fills the canvas.
- Clean up transparent PNGs: transparent pixels always count as background, so alpha icons keep only their content.
- Pre-process before scaling: trimming first gives consistent visual sizes instead of sizes inflated by padding.
- Different from centre cropping: that tool cuts a fixed shape (and may cut content), this one follows the content bounds and only removes background.
Example
Input
A 6×6 white image with 2×2 red content at coordinates 2..3
Output
2×2 starting at (2, 2), 32 pixels removed
From the pure autoTrim logic: the top-left pixel (255,255,255) is the reference colour, so with tolerance 12 the whole background qualifies and the min/max coordinates of the non-background pixels define the crop. With padding = 1 the result grows back to 4×4.
Frequently asked questions
How is the background detected?
The top-left pixel RGB is the reference colour and every other pixel is compared against it with the distance tolerance. Pixels with alpha = 0 always count as background regardless of colour. You can also set an explicit colour such as #ffffff.
Does JPEG noise affect the trim?
Slightly, which is why the default tolerance is 12. White areas in JPEGs often sit near 250 rather than 255, so raising the tolerance to 16–32 makes detection reliable. Too high a tolerance will start eating light-coloured content.
What if the whole image is background?
You never get a zero-sized output: the tool returns the centre 1×1 pixel instead (shown as 1 × 1), so the export is always a valid image.
What is "keep padding" for?
Trimming right to the content can feel cramped. Filling in 4–16 adds a little margin back, from 0 to 512; it only applies inside the original bounds and never enlarges the canvas.
Are my images uploaded?
No. Pixels are read through the canvas and processed entirely in the browser; there is no upload endpoint on the page.
Keywords:auto trimtrim whitespacetrim image