Nodes/was-node-suite-comfyui/Mask Crop Region
ComfyUI Node Runs on cloud

Mask Crop Region

Crop to the masked area and get crop_data to paste it back

By WASasquatch·Created 3 years ago·Updated 2 days ago· 1,839
Mask Crop Region
  • mask
  • cropped_mask
  • crop_data
  • top_int
  • left_int
  • right_int
  • bottom_int
  • width_int
  • height_int
padding24
region_type

This is the node that makes "crop the region, fix it at full resolution, paste it back" possible in a WAS-based workflow. It finds a region in your mask - either the dominant (largest) blob or the minority (smallest) - crops to it, and critically, hands you back crop_data: the record of where it cropped from, so you can paste the fixed region back into its exact original spot later.

That crop_data output is the important part. Cropping is easy; putting the piece back where it came from without misalignment is the annoying part, and crop_data is the receipt that makes the round-trip clean.

Why you'd reach for it

This is the WAS version of the single most important pattern in modern inpainting: don't repaint the whole frame, crop out just the region that needs work, generate it at proper resolution, and composite only that piece back. A face that's 80×80 pixels in a 1024×1024 image gets almost no model attention and comes out mangled; crop it out, and now those same 80 pixels get rendered at full generation resolution. That's the entire idea behind detail passes (Impact Pack's whole detect-crop-refine loop is built on it), and it's why the 2026 community consensus is to composite the fixed region back rather than run the whole image through another VAE cycle and degrade everything.

Mask Crop Region gives you the crop and the coordinates to reverse it. Do your work on the cropped piece, then use the location/size data to paste it back exactly.

How it works

You give it a mask. It locates the region you asked for - dominant or minority - optionally pads it (so you're not cropping right against the edge of the subject), and crops to that bounding box. Alongside the cropped mask it outputs the geometry: the crop_data blob plus the region's location and size as numbers, which the pack explicitly notes you can feed into other nodes "like Crop Image Location" to crop the matching image to the same box.

The inputs and outputs that matter

  • mask - the input mask to find a region in.
  • region type - dominant (largest area) or minority (smallest). Pick which blob you care about.
  • padding - pixels of breathing room around the region. Add some; cropping tight to the subject makes for ugly paste-backs.

Outputs: the cropped MASK, the crop_data (your paste-back receipt), and the region's location and size as numbers to drive matching image crops.

Installing it

Part of WAS Node Suite. ComfyUI Manager: search WAS Node Suite, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui

install requirements.txt against your ComfyUI Python, restart.

Common issues

Paste-back is misaligned. Almost always a mismatch between the crop_data / location used to crop the image and the one used to paste it back. Use the same geometry outputs for both the crop and the paste. WAS's Image Paste Crop node consumes crop_data for exactly this.

Cropped too tight, ugly seams. Bump the padding. Too little padding means the fixed region butts right against unfixed pixels with no room to blend.

It grabbed the wrong blob. Dominant vs minority is doing what you told it. If your target isn't the largest region, switch to minority - or clean the mask first (threshold/fill) so the region you want is actually the dominant one.

All WAS nodes gone after an update. Pack-level. WAS Node Suite is retired and unmaintained; its dependency pins collide with ComfyUI updates and throw "Import Failed," removing every WAS node until you reinstall the pack's requirements against the correct ComfyUI venv.

For a fully modern take on this same round-trip, the community standard is now the dedicated Inpaint Crop-and-Stitch node pair, which never runs unmasked pixels through the VAE at all. But if you're already in a WAS graph, Mask Crop Region plus Image Paste Crop does the job with tools you already have.

CategoryWAS Suite/Image/Masking

Inputs (3)

NameTypeDefaultDescription
maskMASKThe mask to crop. The tightest box around everything non-black in it decides where the crop window sits. Every mask of a batch is cropped to the window measured on the first, so one crop_data describes all of them.
paddingINT240–4096Extra room left around the bounding box before it is squared off, in pixels per side. 0 crops tight; larger values take in more of the surroundings, up to the edges of the image.
region_typeCOMBOWhich region the crop window is measured on. `dominant` takes the largest connected area the mask marks, which is the subject in a mask that also caught specks; `minority` takes the smallest. A mask holding one region crops the same either way.

Outputs (8)

NameTypeDescription
cropped_maskMASKThe mask cut down to the crop window, ready to be worked on at a higher effective resolution.
crop_dataCROP_DATAThe window's size and position, to wire into Mask Paste Region so the crop can be put back exactly where it came from.
top_intINTY coordinate of the window's top edge in the source mask, in pixels.
left_intINTX coordinate of the window's left edge in the source mask, in pixels.
right_intINTX coordinate of the window's right edge in the source mask, in pixels.
bottom_intINTY coordinate of the window's bottom edge in the source mask, in pixels.
width_intINTWidth of cropped_mask in pixels. Smaller than the padded square when the window ran off the side of the image.
height_intINTHeight of cropped_mask in pixels. Smaller than the padded square when the window ran off the top or bottom of the image.