Nodes/ComfyUI-UtilsCollection/Crop Staged Layers by Index
ComfyUI Node

Crop Staged Layers by Index

Pull your subjects back out of the composite

By silveroxides·Created 2 months ago·Updated about 7 hours ago· 24
Crop Staged Layers by Index
  • image
  • layer_masks
  • Images
layer_indices0

You composed a scene, you placed your subjects, everything looks great - and now you want each subject back out as its own clean crop. That's this node's entire job. UC_StagedLayerCrops takes a composed image, a mask batch in layer order, and a list of layer indices, and returns an ordered list of tight, zero-padding crops for just the layers you asked for.

How it works

Three inputs. image is the composed scene (the output of UC_StagedLayeredBackgroundComposite). layer_masks is a MASK batch in the compositor's layer order - which the composite node hands you directly via its Layer Masks output, so the pairing is automatic. layer_indices is a string of zero-based indices, separated by commas or spaces, in the order you want them out - "2, 0, 1" gives you layer 2 first, then 0, then 1.

For each selected index, the node takes the matching mask, finds its tight bounds, and crops the composed image to exactly that region - no padding. Output is a single Images output (IMAGE list), one crop per requested index, in your requested order.

When you'd reach for it

Any time the composite is a working scene but your deliverables are per-subject. Say you staged three characters on a background, liked the framing, and now want each character's crop for a face-detail pass or a per-subject save. Or you want to re-crop only layers that changed without touching the rest. Because the layer order in layer_masks comes straight from the composite node, this is a natural tail to that workflow: composite → crops → detail pass per subject. The no-padding tight bounds also make it handy for feeding crops into an upscaler without extra border junk.

The inputs that matter

  • layer_indices - this is the one you'll actually edit. "0" (the default) crops just the first layer; "0, 2" gives you layers 0 and 2, in that order. Duplicates are allowed if you want the same layer twice (rare, but legal).
  • layer_masks - must be in the compositor's layer order. Wire the composite node's Layer Masks output and you don't have to think about it.

Install

Part of ComfyUI-UtilsCollection:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection

Restart, or use ComfyUI Manager (search "UtilsCollection"). No model downloads - pure image/mask math. The pack's opencv-python requirement handles the resizing/cropping and auto-installs.

Gotchas

Two things to keep straight. First, index ordering: layer_indices is your output order, not a filter that preserves the original order - if you type "2, 0" you will get layer 2 first. Second, tight bounds means crops hug the mask; if a mask is noisy or feathered, the crop bounds can be ragged around the edges. Clean your masks (threshold, feather) upstream in the composite's options if your crops look sloppy. And the standard pack note: this is part of a pack that re-registers node IDs from several older packs, so accept the "replace node?" prompt on workflow load without worry.

Categoryutils/image

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
layer_masksMASKMask batch in staged compositor layer order; each selected index uses the matching mask to crop the composed image.
layer_indicesSTRING0Zero-based layer indices in output order, separated by commas or spaces. Crops use tight bounds with no padding.

Outputs (1)

NameTypeDescription
ImagesIMAGE