ComfyUI Node

NIX_MaskCrop

Give a tiny masked region a full-res generation budget — NIX_MaskCrop is the crop half of crop-fix-paste

By J-ChenX·Created 11 months ago·Updated 11 months ago· 2
NIX_MaskCrop
  • original_image
  • mask
  • crop_image
  • crop_mask
  • pipe
width768
height1024
expand0.20
blur4.0
filling_methodfilling
binarizefalse

NIX_MaskCrop is the node that makes small fixes not look like small fixes. Its whole job: take a mask, find the region it marks, crop that region out of your image, and hand you a clean, correctly-sized crop to regenerate. The reason this matters is resolution economics. A face that's 80×80 pixels inside a 1024×1024 frame gets 80×80 worth of model attention and comes out wrong. Crop that region first, and it gets its own 1024px of generation budget - a 64px eye suddenly has a full-res canvas to itself. That's the entire trick behind Impact Pack's detailers and the "only-masked at full resolution" pattern, and this node gives it to you in three inputs.

It's the "crop" half of the NIX crop-fix-paste loop. The other half is NIX_ImageComposite, which pastes your regenerated crop back onto the untouched original using the pipe this node hands you. Install the pack once and both are yours.

How it works

Give it a mask (required - it errors if you don't) and optionally an original_image. It finds the bounding box of everything nonzero in the mask, adjusts that box to match your target width / height aspect ratio, then:

  • expand (default 0.2) scales the crop box outward so you get context, not just the hard mask edge. 0.2 = 20% bigger. This is the "padding" dial - for detail fixes you usually want some.
  • blur (default 4) feathers the mask edges so the regenerated region blends into the original instead of ending in a hard seam. The actual blur radius scales with crop size, so it stays sane on big crops.
  • filling_method - filling pads the crop with mid-gray around the mask; move shifts the crop window instead of padding. Default filling is right for most inpainting; move is for when you'd rather reposition the window than invent filler.
  • binarize (optional, off by default) snaps the mask to pure 0/1 at a 0.5 threshold before cropping - handy if your mask is a soft gradient and you want a crisp boundary.

Outputs: crop_image and crop_mask (both resized to width×height), plus the pipe - a PIPE_LINE dict holding the crop's coordinates, size, and mask, which is exactly what NIX_ImageComposite reads to paste things back in the right place.

The workflow

NIX_MaskCrop → your KSampler (with the mask as the inpaint condition, and crop_image as the base) → NIX_ImageComposite. The unmasked pixels never touch the sampler, so the rest of your frame stays bit-identical. That's the discipline the inpainting community spent years shouting about - "please composite after inpainting" - made structural.

If you skip the original_image, the node builds a gray placeholder from the mask, which is fine for mask-only testing but useless as a real crop. Pass the real image.

Getting it installed

Same pack as the rest of NIX - one install gets you everything, no model downloads:

  • ComfyUI Manager: search "NIX" / "NIX ComfyUI Plugin", or Install Custom Nodes → Git URL → https://github.com/J-ChenX/ComfyUI-NIX. Restart after.
  • By hand:
    cd ComfyUI/custom_nodes
    git clone https://github.com/J-ChenX/ComfyUI-NIX
    
    Restart ComfyUI. It lives under the "NIX" category. Dependencies are just numpy and Pillow, both already present.

Things that will bite you

  • The pipe is NIX-specific. It stores NIX's own keys, so composite it only with NIX_ImageComposite. Other packs' PIPE_LINEs won't interoperate.
  • Empty mask = whole image. If the mask is all zeros, the node falls back to cropping the entire frame. If your crop comes back huge, check the mask, not the settings.
  • Defaults are face-ish. 768×1024 at 20% expand works for a portrait region; a tiny detail fix may want a smaller width/height and more expand so the model has context.
  • Batch alignment is silent. Image and mask batches get reconciled by repeating/truncating the last item. Fine in practice, confusing when debugging.
  • Zero community presence. This pack has almost no forum footprint as of mid-2026, so don't expect a shared NIX workflow to copy. The source is one readable Python file if you want the exact geometry.
CategoryNIX

Inputs (8)

NameTypeDefaultDescription
widthINT76864–4096
heightINT102464–4096
expandFLOAT0.200–101
blurFLOAT4.00–128
filling_methodCOMBOfilling2 options: filling, move
original_imageoptIMAGE
maskoptMASK
binarizeoptBOOLEANfalse

Outputs (3)

NameTypeDescription
crop_imageIMAGE
crop_maskMASK
pipePIPE_LINE