Trim transparent pixels from a PNG
Trim the transparent border off a PNG here, in the browser, with no install and no upload. Drop one file or fifty; each is trimmed to its own content and can be downloaded individually or as a ZIP.
Below: how this compares with Photoshop, GIMP, Preview and ImageMagick, and the specific thing each of them gets wrong.
Drop image here
or
PNG, WebP or JPG · up to 50 MB · you can also paste from the clipboard
Your images are processed locally in your browser.
Ways to trim a PNG, compared
| Tool | How | Threshold control | Batch | Catch |
|---|---|---|---|---|
| AutoCrop | Drop the file in this page | Yes, alpha 0–254 | Yes, ZIP output | Output is always PNG; needs a modern browser |
| Photoshop | Image > Trim → Transparent Pixels | No — keeps any non-zero alpha | Only via an Action plus Batch | Cannot cut into a soft shadow at all |
| GIMP | Image > Crop to Content | No | Only via Script-Fu | Same shadow limitation, and no threshold |
| ImageMagick | magick in.png -trim +repage out.png | Yes, via -fuzz | Yes, mogrify | Forgetting +repage silently keeps the old canvas |
| macOS Preview | Manual rectangle selection | Not applicable | No | Not really trimming — you eyeball the rectangle |
| Most online croppers | Upload, then manual or automatic crop | Rarely | Sometimes | Your image is uploaded to someone else’s server |
The threshold is what the desktop tools lack
Photoshop and GIMP both trim on “is this pixel transparent or not”, a binary test. Any pixel with an alpha value of 1 counts as content. For a flat logo that is exactly right, and all three tools give an identical result.
For anything with a drop shadow it is not enough. A blurred shadow extends a gradient of nearly invisible pixels dozens of pixels past the shape, and a binary test has to keep all of them. Photoshop offers no way to say “ignore anything under 20 percent opacity”, so the only workaround is hiding the shadow layer, trimming, and putting it back — which changes the composition you were exporting.
A threshold turns that into a slider. On a 340 × 340 shadowed icon, alpha > 5 gives 262 × 270 while alpha > 96 gives 216 × 224, the visible disc. The full measurement is on the home page.
When you should not trim
Automatic trimming is the wrong move more often than people expect:
- Icon sets that must stay a consistent size. Trimming each file to its own content makes every icon a different size, and a 24 px grid falls apart. Trim the source artwork once, then export at fixed sizes.
- App icons and store assets. Platforms specify exact dimensions and safe-area margins; the transparent padding is required, not accidental.
- Sprite sheets that are still assembled. Trim the individual frames before packing, never the packed sheet.
- Images whose transparent margin is deliberate spacing in a layout that references fixed pixel offsets.
- Anything where the shadow is part of the design and must not be clipped — keep the threshold low, or trim with padding added back.
Trimming PNGs: questions
- What does "trim" mean for an image?
- Trimming removes uniform border pixels — transparent, or all one colour — until the edges of the canvas touch actual content. Unlike cropping, you do not choose the rectangle: it is derived from the pixels. The word comes from Photoshop, whose Image > Trim command does exactly this.
- Is trimming the same as cropping?
- Cropping is manual: you pick a rectangle. Trimming is automatic: the rectangle is computed from the content. AutoCrop trims, then optionally pads the result back out.
- Does trimming a PNG lose quality?
- No. The kept pixels are copied unchanged and re-encoded as lossless PNG. Nothing is resampled, rescaled or recompressed with loss.
- Can I trim many PNGs at once without installing anything?
- Yes. Select or drop multiple files and each is trimmed to its own content bounds, then download them together as a ZIP. Everything runs in the browser tab.
- Why does Photoshop trim less than I expected?
- Image > Trim with Transparent Pixels keeps every pixel with any opacity at all, which on a soft drop shadow means the near-invisible outer edge. It has no threshold setting, so you cannot ask it to cut deeper. AutoCrop exposes that threshold.
Related
- Crop transparent PNGHow PNG alpha works, and what each PNG variant means for cropping.
- Trim in PhotoshopImage > Trim step by step, its shadow problem, and batching it.
- Trim with ImageMagickThe -trim command done right, including the +repage trap.
- AutoCropThe main tool: detect content bounds and trim the transparent margin.