Nodes/ComfyUI-SuperNodes/🐧 Crop Image using Mask
ComfyUI Node

🐧 Crop Image using Mask

Crop a face (or anything) to a mask so the model spends its pixels where they matter

By sonnyboxΒ·Created 11 months agoΒ·Updated 4 days agoΒ· 12
🐧 Crop Image using Mask
  • image
  • mask
  • cropped_image
  • cropped_mask
  • uncrop_info
β—„padding0β–Ί
β—„multiple_of16β–Ί

The single most reliable way to fix a bad face in ComfyUI is the crop-regenerate-paste pattern: cut the face region out, run it through the model at a resolution it can actually work with, then paste the result back. That's what "only masked" inpainting means, and it's the technique the community settled on precisely because a 64-pixel eye is invisible to a model generating at 1024px. This node is the crop half of that pattern, and it's built to hand the metadata to its sibling so the paste half never has to guess.

It's part of the 🐧 SuperNodes pack by SuperCC, and it pairs with Restore Mask Crop - you crop here, process the crop anywhere, then restore over there.

How it works

Give it an image and a mask. The mask gets binarized at 0.5, the node finds the bounding box of everything above that threshold, and that box is what gets cropped. Two knobs matter:

  • padding - pixels added around the bbox on all sides (default 0, up to 4096). For face fixes the community guidance is 32–64px; a tight crop leaves no room to blend the edges back in.
  • multiple_of - the crop dimensions are rounded up to a multiple of this (default 16, and the tooltip is blunt about why: "critical for UNet based processing"). Rounding is applied centered, so the face doesn't drift to one corner.

Outputs are cropped_image, the matching cropped_mask, and uncrop_info - the metadata (crop coordinates, original size, and a stored copy of the crop-space mask) that Restore Mask Crop needs to put everything back. Keep that wire connected; losing it means restoring blind.

One nice safety behavior: if the mask is entirely empty, it doesn't error - it returns the full image and a no-op uncrop_info, so a workflow with an accidentally-empty mask degrades gracefully instead of killing the queue.

When you'd reach for it

  • Face or hand detail passes: crop the region, encode at native resolution, restore.
  • Any region-based fix where you want the rest of the image bit-identical - the thing mask-inpainting still owns over whole-frame edit models, per the community consensus on why mask-based work survives.
  • Preparing crops for a dedicated inpaint model that wants tight, padded regions.

Install

ComfyUI Manager, search "ComfyUI-SuperNodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/sonnybox/ComfyUI-SuperNodes

Restart ComfyUI. No model downloads, no real dependency beyond the pack's matplotlib (used only by Sigmas Graph). Keep ComfyUI updated - this pack is built on the newer extension API and silently won't load on very old builds.

Gotchas

  • Multiple separate mask blobs get one bounding box covering all of them. For one face that's correct; for scattered regions you'd want one crop per blob, which this node deliberately doesn't do.
  • Padding and multiple_of rounding both clamp to the image edges, so a face near the border gets asymmetric padding. Usually harmless, occasionally visible as a lopsided blend - add more padding than you think you need.
  • The crop rounds up to multiple_of, which can make the crop a bit bigger than the mask. Again: padding is your friend.

It's a two-output-plus-metadata crop node that does exactly one thing well. Chain it with Restore Mask Crop and you've built the core of half the face-fix workflows people actually ship.

CategorySuperNodes/Image

Inputs (4)

NameTypeDefaultDescription
imageIMAGEThe source image to be cropped.
maskMASKThe binary mask defining the region of interest to crop.
paddingINT00–4096Amount of padding (in pixels) to add around the mask bounding box.
multiple_ofINT161–512Ensure the crop dimensions are a multiple of this value.

Outputs (3)

NameTypeDescription
cropped_imageIMAGEThe cropped image region.
cropped_maskMASKThe cropped mask region.
uncrop_infoCROP_INFOMetadata containing coordinates and original size, required for restoration.