Crop to Content
Trim transparent padding off a batch automatically
- images
- alpha
- images
- alpha
Transparent PNGs frequently have more empty margin than actual content - a character render sitting in the middle of a much larger transparent canvas, say - and trimming that dead space by hand, frame by frame, isn't realistic once you're dealing with a batch. Crop to Content automates it: it finds the bounding box of the actual non-transparent content and crops the whole batch down to just that.
How it works
It's a tighter, simpler cousin of Auto Cropper elsewhere in this pack - no method selection, no sensitivity tuning, just "find the non-transparent content and crop to it." What tells it where content is versus background is transparency: your images' own alpha channel, or an explicitly connected mask if you have one.
The inputs and outputs that matter
images(IMAGE, required) - the batch to crop.alpha(MASK, optional) - connect this if you want explicit control over what counts as "content" rather than relying on the images' own alpha channel. Without transparency information from one source or the other, there's nothing for the node to distinguish content from background with.
Two outputs, matching the inputs: images (IMAGE) - the cropped batch - and alpha (MASK), cropped and aligned to match.
How to install it
ComfyUI Manager: search "Link Comfy Nodes," install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
pip install -r link-comfy-nodes/requirements.txt
Restart ComfyUI when done.
Common issues & troubleshooting
Nothing gets cropped, or the crop is wrong. If your images don't actually carry an alpha channel - a plain RGB PNG, or a JPEG, which has no transparency at all - and you haven't connected the optional alpha mask either, this node has no signal to work from. Make sure you're either loading genuinely transparent PNGs or explicitly wiring in a mask.
Different frames crop to different sizes. Since each frame's content bounding box is found independently, a batch where the subject's silhouette changes size or position between frames can produce inconsistent crop dimensions across the batch - which will break anything downstream that expects a uniform batch shape. If you need every frame the same size afterward, pad or resize back to a common dimension after this node, or crop to a shared box via Crop by BBox instead if consistency matters more than a tight fit.
Content touching the very edge gets clipped. If your subject extends right to the canvas boundary with no margin, a tight content-crop can end up cutting flush against it with zero breathing room. If you need a little space, this node has no padding control of its own - route the output through Crop by BBox afterward if you want an explicit margin added back in.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| alphaopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| alpha | MASK | — |