Cut By Mask
Crop exactly what's masked, nothing else
- image
- mask
- mask_mapping_optional
- IMAGE
Cut By Mask does the "crop" half of what's now the standard high-resolution inpainting recipe: mask a region, cut it out at full detail, do your work on just that piece, paste it back. It's a small, unglamorous node, but it's the one that lets you spend your model's generation budget on the part of the image that actually needs it instead of the whole frame.
The point of cutting first is resolution. If you're fixing a face that occupies 100x100 pixels of a 1024x1024 image, sampling the whole frame gives that face 100x100 pixels worth of attention no matter what resolution you generate at. Cut it out, and suddenly that same region can be resampled at 512x512 or more - four or five times the detail budget for the part you actually care about. This is the same idea behind the now-popular Inpaint Crop and Stitch pattern and behind Impact Pack's detailer nodes; Cut By Mask (paired with Mask To Region for sizing and Paste By Mask for the composite) is Masquerade Nodes' version of that same loop, and it predates most of the alternatives.
The inputs that matter
- image - the image (or mask) to cut the masked area out of.
- mask - the mask specifying what to keep.
- force_resize_width / force_resize_height - if either is non-zero, the cut result is resized to that size. Leave both at 0 to keep the natural crop size.
- mask_mapping_optional - only wire this if the mask came out of a Separate Mask Components node upstream (i.e. you've got a variable number of masks per image). It makes sure each mask gets matched to the correct source image. Leave it unwired otherwise.
Output is the cropped image (or mask), with alpha applied outside the mask's boundary if the mask isn't a clean rectangle - that alpha channel matters later, because Paste By Mask respects it: zero-alpha pixels won't get pasted back.
A couple of things worth knowing before you build around this: if you're cutting multiple images/masks in a batch and haven't forced a resize, everything gets resized to match the size of the largest crop - which can distort your masks if the batch's regions vary a lot in aspect ratio. The fix, straight from the pack's own tips, is to run your mask through Mask To Region with keep_ratio constraints first, so every crop in the batch comes out at a consistent aspect ratio before it hits this node.
Installing it
Cut By Mask is part of Masquerade Nodes. Install through ComfyUI Manager (search "Masquerade Nodes") or clone it manually: cd ComfyUI/custom_nodes && git clone https://github.com/BadCafeCode/masquerade-nodes-comfyui, then restart ComfyUI. No model downloads, no extra pip packages for this one - it's a crop-and-alpha operation, nothing more. Worth a mention since it colors how you should think about the whole pack: the README calls this a dependency-free library, built before ComfyUI Manager existed to make dependency handling painless, and the author's own recommendation is to reach for Impact Pack instead unless that dependency-free property specifically matters to you. For a straightforward "cut this region out" node like this one, either works fine - it's really a call about the rest of the pack.
Common issues
The failure mode people actually hit is a mismatch between what got cut and what gets pasted back later: if you crop with Cut By Mask and then modify the mask before pasting (say, running it through Mask Morphology in between), the size and position Paste By Mask computes can shift, and your result lands in the wrong spot or at the wrong scale. Keep the mask you cut with and the mask you paste with either identical, or deliberately related through mask_mapping_optional when working with Separate Mask Components' batch output - mixing the two without that mapping is the most common way this pattern silently breaks.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | IMAGE | — | |
| force_resize_width | INT | 00–1048576 | — |
| force_resize_height | INT | 00–1048576 | — |
| mask_mapping_optionalopt | MASK_MAPPING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |