← Back to Home

✂️ Auto Trim White Edges

Scan the four sides, find rows and columns that are all the same colour, and crop them away in one click.

How to trim white edges in three steps

The screenshot below was taken in this tool with a real file and the stated settings — it is not a mock-up.

  1. Upload the scanPhotos with a uniform white or coloured margin work best.
  2. Set the toleranceThis run uses tolerance 18 with corner sampling.
  3. Trim and checkPress “Trim edges”; the report says 80/80/80/80 px removed, leaving 1200 × 800.
Trim result: the white border removed from the scan, with a report of 80 pixels removed on each side.
Captured: Input: specimen-border-1360x960.png (1360 × 960 PNG with an 80 px white border). Settings: tolerance 18, corner sampling. Output: PNG, 1200 × 800 (80 px removed on each side).
📁
Click or drag an image here
PNG · JPG · WebP · GIF · BMP · SVG · AVIF · ICO · HEIC / HEIF

Original

Original

Trimmed result

Result
Rounded mode also clears the four corner wedges left by round corners and anti-aliased edges.
18

How to use this tool

  1. Upload a screenshot, scan or product shot with a uniform border.
  2. Keep "four corners" sampling, or pick the exact edge colour yourself.
  3. Raise tolerance if the border has slight compression noise or a soft gradient; lower it for strict matching.
  4. Trim and download. The result info shows exactly how many pixels were removed on each side.

Note: All processing happens in your browser: images are never uploaded. Gradients and shadows are the known limit of this automatic method.

How it works

The tool reads the image into a pixel buffer, samples the border colour from the four corners, then walks inward: a row is considered empty when all sampled pixels match that colour within the tolerance, and likewise for columns. The bounding box of non-empty pixels is kept.

It is a deterministic formula, not a learned model. That means gradients, drop shadows and anti-aliased edges can be misread as content — the tolerance slider and the result readout let you check before downloading.

Common use cases

Scanned documentsCut the scanner bed borders so the page fills the frame.
Product shotsRemove the uniform white margin before building a listing collage.
ScreenshotsStrip an empty band from a long capture without manual measuring.

Frequently asked questions

Why was nothing trimmed?
The border is probably a gradient, has a shadow, or differs from the four corners. Raise tolerance or pick the edge colour manually.
Why did it crop too much?
Tolerance is too high and real content near the edge matches the background. Lower it and try again.
Does it work on transparent images?
Yes. Fully transparent pixels count as background, so transparent padding is trimmed too.
Is my image uploaded?
No. The pixel scan runs locally in your browser.

What "background" means to this scanner

The tool does not look for white. It builds a reference colour and then asks, for each pixel, whether that pixel is close enough to the reference. Two things decide the answer:

  • The reference. In the default mode it is the average of the four corner pixels, rounded per channel. If the corners differ — sky at the top, grass at the bottom, a drop shadow on one side — the average is a colour that appears nowhere in the image, and almost nothing gets trimmed. Switching to "Pick a colour" and choosing the actual border avoids that trap entirely.
  • The tolerance, measured as a cube. A pixel passes when the absolute difference in red, in green and in blue is each at most the tolerance. That is a box in colour space, not a sphere: at tolerance 18 a pure white reference accepts channel values from 237 to 255, so a cyan-tinted white at (237, 250, 255) passes while a warm grey at (255, 240, 240) fails on the green and blue channels.

Fully transparent pixels count as background regardless of their colour, because their alpha is below 16. Transparent padding therefore disappears without any tolerance fiddling.

The scan samples, it does not inspect every pixel

Each row is tested by stepping across it in strides of max(1, floor(width / 240)) pixels — at most about 240 samples per row, and the same rule vertically for columns. On a 3000 px wide image that is a sample every 12 px. A one-pixel hairline running the full width, or a spike of content that happens to land between samples, can be missed, and the row is then judged empty and removed. This is the mechanical explanation for "it cut off a thin part of my chart": the scan is a sampler, and the sampler skipped it.

The four sides are trimmed in sequence — top, bottom, left, right — and each pass searches within the original bounds. A border that is only present on the left and right is handled correctly. A border interrupted by a bright element touching one edge stops that edge's pass at the interruption, which is why a scan with a page number in the margin often keeps a thin strip.

Rounded mode and its hard limit

The second mode additionally clears the four corner wedges left behind by rounded corners and anti-aliased edges. It does this with a flood fill seeded from each corner, following pixels that match that corner's own colour, and setting their alpha to zero. The fill is skipped entirely when width × height exceeds four million pixels — a number that is reachable here, since the working canvas allows up to 3000 × 3000. Above that the result note says corner cleanup was skipped, and the output keeps its wedge-shaped corners. If that happens, run the trim on a smaller copy, or clear the corners with the Rounded Corners tool after trimming.

Reading the result line

After processing, the line under the preview reports the pixels removed from the left, right, top and bottom, followed by the new dimensions. Those four numbers are the fastest way to catch a bad pass: if the left value is zero on a scan that clearly has a margin, the reference colour is wrong. If the top value is hundreds of pixels on a document with a header, the tolerance is too high. Nothing is written to disk until the download button is pressed, so an incorrect pass costs one more click, not a lost file.

Where this stops being the right tool

  • Gradients and shadows. A photographed page with a soft shadow along one side is not a uniform border; the shadow's edge becomes the new boundary and the trim lands in the wrong place. Use Crop Image and cut by eye.
  • Interior whitespace. Only the outer boundary is examined. A white band inside a screenshot stays, which is correct — trimming it would change the layout.
  • Background removal. Removing a white background behind a product is a different operation. This tool only crops the rectangle; the Palette Extractor and the transparency tools are not substitutes either.
  • Exact pixel targeting. If the result must be 1080 px wide, trim first and then resize; trimming never produces a round number by design.

Output is a PNG at the trimmed size with the original alpha preserved. There is no undo, so the untouched upload remains the master copy.

Two more questions this page gets

Why did it trim a border that was not one colour?
Because the tolerance is a per-channel cube, not a strict equality test. At 18, a border whose channels vary by up to 18 each is treated as one colour. Lower the tolerance to 6–10 for a noisy but genuinely uniform border; the option to pick the colour manually also narrows the reference considerably.
Does trimming change the image resolution or recompress it?
It crops the canvas and re-encodes as PNG, so the retained pixels are copied one to one at their original scale — no resampling, no softening. Only the area outside the retained rectangle is discarded.
Processing, please wait…