Nodes/Link Comfy Nodes/Auto Cropper
ComfyUI Node

Auto Cropper

Four ways to find the subject and crop to it

By Mister-Link·Created 9 months ago·Updated 23 days ago· 0
Auto Cropper
  • frames
  • alpha
  • cropped_frames
  • cropped_alpha
  • bbox
methodbg_sub
sensitivity0.50
padding5
padding_color#000000
use_image_paddingfalse
pad_edge_pixelfalse

Content-aware cropping across a whole video batch is a genuinely fiddly problem: what counts as "the subject" changes depending on whether you're working with a clean background, an anime-style character, or footage with real background clutter. Auto Cropper doesn't pretend one method covers every case - it gives you four different detection strategies to choose from, then applies the resulting crop consistently across your frame batch.

How it works

Pick a detection method, and the node finds a bounding box around what it decides is the subject in each frame, then crops to it - with padding and edge-handling options to control what fills any gap. It also hands the detected box back out as a string, which pairs directly with Crop by BBox elsewhere in this pack: run detection once here, then reuse the exact same box on a different resolution pass or a different batch without re-detecting.

The inputs and outputs that matter

  • frames (IMAGE, required) - the batch to crop.
  • method (enum, default bg_sub) - four choices: bbox, non_black, anime, bg_sub. bg_sub (background subtraction) is the default and generally the one to start with; non_black is useful after letterboxing or padding removal; anime targets anime-style character segmentation specifically.
  • sensitivity (FLOAT, default 0.5, 0–1) - how aggressively detection triggers. Push it up if it's missing your subject, down if it's grabbing too much background.
  • padding (INT, default 5, 0–500) and padding_color (STRING, default #000000) - margin around the detected box and its fill color.
  • use_image_padding (BOOLEAN, default false) - per the author's tooltip: "If true, padding area is taken from the original frame when in bounds; out-of-bounds area uses padding_color."
  • pad_edge_pixel (BOOLEAN, default false) - the author's note: "If true, padding is filled by stretching the outermost edge pixels of the crop outward (like a replicated border). Overrides padding_color and use_image_padding when enabled." This is usually the cleanest-looking padding option when you don't want a visible solid-color border.
  • alpha (MASK, optional) - feed in an existing mask to assist or refine detection.

Three outputs: cropped_frames (IMAGE), cropped_alpha (MASK), and bbox (STRING) - that last one is the string that feeds straight into Crop by BBox.

How to install it

Through ComfyUI Manager: search "Link Comfy Nodes," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
pip install -r link-comfy-nodes/requirements.txt

Restart ComfyUI afterward.

Common issues & troubleshooting

Wrong method for your footage. bg_sub assumes a reasonably distinguishable background from the subject; if your source has a busy or moving background, it'll misfire. Try non_black if your frames have solid padding around real content, or anime if you're working with flat-shaded character art specifically - the wrong method for your content is the single most common cause of a bad crop here, before you even touch sensitivity.

Crop jitters frame to frame. Because detection runs independently per frame by default reasoning, a subject that changes shape or position can produce a slightly different box each frame, giving a shaky, jittery final crop. If that's visible, consider running detection on a representative frame, grabbing that single bbox, and applying it uniformly via Crop by BBox instead of trusting per-frame detection for the whole batch.

Edges look like a hard colored border. That's padding_color doing exactly what it's set to do. If you want the padding to blend rather than stand out, switch to pad_edge_pixel - it stretches real edge pixels outward instead of filling with a flat color, which reads far more natural in most footage.

Categoryimage/transform

Inputs (8)

NameTypeDefaultDescription
framesIMAGE
methodCOMBObg_sub4 options: bbox, non_black, anime, bg_sub
sensitivityFLOAT0.500–1
paddingINT50–500
padding_colorSTRING#000000
use_image_paddingBOOLEANfalseIf true, padding area is taken from the original frame when in bounds; out-of-bounds area uses padding_color.
pad_edge_pixelBOOLEANfalseIf true, padding is filled by stretching the outermost edge pixels of the crop outward (like a replicated border). Overrides padding_color and use_image_padding when enabled.
alphaoptMASK

Outputs (3)

NameTypeDescription
cropped_framesIMAGE
cropped_alphaMASK
bboxSTRING