LayerUtility: ImageAutoCrop V3(Advance)
ImageAutoCrop V3 — ComfyUI Node Guide
- image
- mask
- cropped_image
- box_preview
V2 of ImageAutoCrop tries to find your subject for you, with built-in SAM/RMBG matting. V3 drops that entirely and goes simpler: you either hand it a mask or you don't, and it crops to your target aspect ratio and size around whatever region that mask (or the raw image) defines. Same "generate consistent training-image material" purpose the README states for the whole ImageAutoCrop family, just with the automatic subject-detection step stripped out in favor of a leaner, faster node.
The mechanism: crop to aspect_ratio, optionally constrained by an input mask so the masked region stays inside the final crop, then resize to your target dimensions using your chosen resampling method, and round the final size to a clean multiple if you need one (handy since a lot of downstream models want dimensions divisible by 8, 16, or 64).
Inputs that decide the output:
image- your source.mask(optional) - if provided, the masked area gets preserved within the cropped aspect ratio; the README is explicit that this is about preservation, not detection - there's no automatic subject-finding here like in V2.aspect_ratio- common ratios (1:1, 3:2, 4:3, 16:9, 2:3, 3:4, 9:16),custom(paired withproportional_width/proportional_height), ororiginalto keep the source ratio.scale_to_side+scale_to_length- resize bylongest,shortest,width,height, or (new in V3)total_pixel(kilo pixel), which targets an overall pixel-count budget rather than a single edge.method- the resampling algorithm for the resize step:lanczos,bicubic,hamming,bilinear,box, ornearest. Lanczos and bicubic are the sharper general-purpose choices; nearest is for when you specifically want blocky, uninterpolated pixels.round_to_multiple- forces final width/height to a multiple of 8/16/32/64/128/256/512, orNoneto skip rounding entirely.
Outputs: cropped_image (the result) and box_preview (a visual of where the crop landed, useful for checking a batch quickly). Note there's no cropped_mask output here, unlike V2 - since V3 isn't generating its own detection mask, there's nothing new to hand back on that front.
Installing it: ComfyUI Manager, search "ComfyUI Layer Style Advance," or git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes, then install_requirements.bat (or Aki variant) / pip install -r requirements.txt, then repair_dependency.bat, restart. This one's a genuine bonus for install simplicity: since it doesn't do its own subject detection, it doesn't need the SAM/GroundingDINO model files V2 requires - if all you're using from this pack is V3, you can skip that whole download.
When to reach for this over V2: if you already have a mask from somewhere else in your pipeline (a previous BiRefNet or SAM pass, a hand-painted mask, whatever), V3 is faster and lighter since it isn't running its own detection pass on top. Reach for V2 instead when you're starting from a raw image with no mask and want the node to find the subject itself. And if the crop looks off with no mask connected, remember V3 without a mask just crops toward the geometric behavior of your aspect_ratio/scale_to_side settings on the whole frame - it won't guess at what the subject is the way V2's built-in matting would.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| aspect_ratio | COMBO | 9 options: 1:1, 3:2, 4:3, 16:9, 2:3, 3:4, +3 | |
| proportional_width | INT | 11–99999999 | — |
| proportional_height | INT | 11–99999999 | — |
| method | COMBO | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest | |
| scale_to_side | COMBO | 6 options: None, longest, shortest, width, height, total_pixel(kilo pixel) | |
| scale_to_length | INT | 10244–999999 | — |
| round_to_multiple | COMBO | 8 options: 8, 16, 32, 64, 128, 256, +2 | |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| box_preview | IMAGE | — |