How to trim transparent pixels in Photoshop

Photoshop has had this feature since the late 1990s and the steps haven't really changed. Here is the short version, the version with all the gotchas, and the case for skipping Photoshop entirely when this is all you need.

The short version

  1. Open the image in Photoshop.
  2. Go to Image → Trim.
  3. Choose Based On: Transparent Pixels.
  4. Leave Top, Bottom, Left, Right all checked.
  5. Click OK.
  6. Export to PNG or WebP via File → Export → Export As.

That's it. The canvas shrinks to the bounding box of the non-transparent pixels.

The version with all the gotchas

1. The image must have an alpha channel

If the file is a JPEG, there is no transparency to trim. JPEG cannot store an alpha channel — that's part of why we wrote a whole page on the alpha channel. You'll need to use Trim Based On: Top Left Pixel Color or Bottom Right Pixel Color instead, which is a different operation and won't produce a transparent result.

2. "Flatten Image" will destroy your transparency

If you accidentally Layer → Flatten Image before exporting, Photoshop replaces every transparent pixel with white. You'll then end up with a white-bordered PNG instead of a tight, transparent one. The fix: undo, or skip flattening entirely.

3. PNGs from older Save For Web are different from Export As

Modern Photoshop ships two export paths. Use File → Export → Export As with Transparency checked. The legacy Save for Web (Legacy) dialog still works but is slower and downsamples some color profiles unexpectedly.

4. Trim doesn't resize, it just shrinks the canvas

Trim removes empty rows and columns at the edges. The visible content stays at its original pixel size. If you also need to scale the result, do that as a separate step via Image → Image Size — or use the Triim resize tool after trimming.

5. Anti-aliased edges sometimes survive the trim

Photoshop's default Trim treats anything with alpha > 0 as "not transparent." A faint 1px halo around your subject can leave the canvas larger than you expect. Two options: clean up the halo with Layer → Matting → Defringe before trimming, or use a tool with a configurable alpha threshold.

The case for skipping Photoshop

Photoshop is the right tool when you are also retouching, masking, or compositing. For a pure trim — open, trim, save — opening Photoshop is over-engineering a one-second operation. A few honest tradeoffs:

Doing the same thing in Triim

The Triim trim tool reproduces Photoshop's Image → Trim → Transparent Pixels in your browser:

  1. Open triim.ca.
  2. Drag your PNG or WebP files onto the drop zone (up to 20 at a time).
  3. Click Process Images.
  4. Download each trimmed file or the entire batch as a ZIP.

The alpha threshold defaults to a value that preserves anti-aliased edges (the "faint halo" gotcha above), so what you see is what you keep. Nothing is uploaded — every pixel stays in your browser, the same way Photoshop keeps them on your local disk.

Related

Last updated: 2026