Nodes/ComfyUI-WJNodes/mask crop option Basic
ComfyUI Node

mask crop option Basic

The config node behind WJNode's mask-cropping

By 807502278·Created 2 years ago·Updated 11 months ago· 21
mask crop option Basic
  • add_option
  • crop_option
inversion_maskfalse
mask_threshold0.010
size_pix0
ExceedingWhite

This node doesn't crop anything by itself. It's a settings node - you configure it, plug its output into mask_crop_square (or another WJNode crop node with an option input), and that's where your settings actually take effect. If you wired this up expecting a cropped image to come out, that's the mix-up to clear first: think of it as a config object, not a processing step.

It belongs to ComfyUI-WJNodes, a personal utility pack from an author who publishes under the handle 807502278 rather than a name. The mask-crop family here (mask_crop_square, this node, and its sibling mask_crop_option_SmoothCrop) implements a version of a pattern that's become the default across the ComfyUI inpainting world: crop tightly around a masked region, do your work at that region's native resolution, then paste the result back - the same idea behind the popular Inpaint Crop and Stitch node and the detail-refiner tools like Impact Pack's FaceDetailer. WJNode's version splits the "how do I want to crop" settings out into their own node, which is what this one is.

What it configures

  • inversion_mask - flip the mask before cropping. Same purpose as the invert toggle on plenty of other mask nodes: sometimes your mask marks the region you want to keep, sometimes the region you want to cut around, and this reconciles the two.
  • mask_threshold - how dark a pixel has to be before it's ignored when figuring out where the mask's boundary actually is. Default 0.01, which means near-black noise or faint anti-aliasing haze around your mask won't drag the crop boundary outward - raise it if your mask has soft, low-opacity edges you want the crop to disregard.
  • size_pix - target output size. Left at the default of 0, the crop uses whatever size the mask region itself dictates rather than forcing a fixed dimension.
  • Exceeding - what to fill with when the calculated crop box runs past the image's actual edge (say, a mask near a corner). Choose White, Black, or Gray depending on what plays nicest with whatever you're feeding the crop into downstream.

The optional add_option input lets you chain multiple option nodes together, which is how this pairs with mask_crop_option_SmoothCrop - set your basic crop behavior here, then layer temporal smoothing on top for video work.

The single output, crop_option, is the config object itself - wire it into the crop node's option input.

Installing it

ComfyUI Manager, search "ComfyUI-WJNodes," or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git

Restart ComfyUI. Nothing heavy here - no models, no extra dependencies beyond a standard ComfyUI environment.

Where people get confused

The biggest source of confusion with this node is exactly what opened this article: it produces no visible output on its own. If your graph looks "done" but nothing's cropped, check that this node's crop_option output is actually connected to a crop node's option input - an unconnected options node just sits there doing nothing, silently.

Because this is a low-traffic personal pack with no discussion threads anywhere to search, there's no community-sourced list of gotchas beyond what's in the README and the node's own default values - if a setting's behavior isn't obvious from its name, the safest move is to test it on one image with extreme values (0 vs. max) and watch what actually changes, rather than guessing from the label alone.

CategoryWJNode/ImageEdit/mask_crop

Inputs (5)

NameTypeDefaultDescription
inversion_maskBOOLEANfalse
mask_thresholdFLOAT0.0100–1
size_pixINT00–8192
ExceedingCOMBOWhite3 options: White, Black, Gray
add_optionoptcrop_option

Outputs (1)

NameTypeDescription
crop_optioncrop_option