Nodes/ComfyUI-Seed-Nodes/Seed-Nodes: ImageTransparencyCrop
ComfyUI Node

Seed-Nodes: ImageTransparencyCrop

Trim the dead space off your transparent PNGs automatically

By Aerse·Created 2 years ago·Updated about a year ago· 5
Seed-Nodes: ImageTransparencyCrop
  • image
  • image
padding0
threshold0.00
batch_strategyindividual

If you've ever cut a subject out of a background and then looked at the result - a tiny sprite floating in a sea of transparent canvas - you know the next problem: all that dead space. It wastes resolution, it throws off batch operations, and it makes training crops and sprite sheets awkward. ImageTransparencyCrop finds the actual bounding box of the non-transparent pixels and crops to it, so your subject fills the frame instead of drowning in it.

How it works

The node takes an image and converts it to RGBA (if your input has no alpha channel, it just adds a fully-opaque one - meaning a plain RGB photo gets cropped to its full bounds, which is correct and useless in equal measure). Then it scans for the bounding box of pixels above a transparency threshold, and crops.

The part worth caring about is batch_strategy, because it exists for a very specific reason. If you're cropping a batch of frames - say, frames of a character animation or a sprite sheet - cropping each frame to its own bounding box (individual) makes the frames different sizes, which breaks any downstream node expecting uniform dimensions. So there are strategies to share one box across the whole batch:

  • first_only - crop everything to the first frame's bounds.
  • largest_size - use the biggest bounding box in the batch for all frames.
  • most_common - the most frequently occurring box size wins.
  • individual - each frame gets cropped to its own bounds (default).

The inputs that matter

  • image - the RGBA image to trim.
  • padding - extra pixels to leave around the subject (0–100). Use this if you don't want the crop hugging the edges.
  • threshold - how transparent a pixel must be before it's treated as empty space (0.0–1.0). Default 0 means only fully-transparent pixels are trimmed. Bump it slightly if you have faint semi-transparent haze or feather edges you'd rather discard.
  • batch_strategy - see above; it's the difference between "works" and "works AND keeps the batch uniform."

Output is a single cropped image.

How to install it

It's part of ComfyUI-Seed-Nodes, so install the pack once:

cd ComfyUI/custom_nodes
git clone https://github.com/Aerse/ComfyUI-Seed-Nodes
# restart ComfyUI

Or ComfyUI Manager → search "ComfyUI-Seed-Nodes". Pure Pillow + numpy under the hood, no model downloads.

Common issues

  • Nothing gets cropped - your input probably has no real alpha (an RGB image, or a "transparent" PNG that was flattened somewhere upstream). The node can't trim what isn't there.
  • Frames come out different sizes - switch batch_strategy away from individual. That's literally what the other three options are for.
  • Crop too tight - add padding. It's the fix for both feather edges and preview nodes that don't show you the boundary.

The node's own description calls itself the "improved version" that fixed batch handling, and that's where the value is: a crop that also keeps your batch uniform is a crop you can actually wire into a pipeline.

CategoryComfyUI-Seed-Nodes

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
paddingINT00–100
thresholdFLOAT0.000–1
batch_strategyCOMBOindividual4 options: first_only, largest_size, most_common, individual

Outputs (1)

NameTypeDescription
imageIMAGE