Nodes/ComfyUI-Pixaroma/Inpaint Crop Pixaroma
ComfyUI Node

Inpaint Crop Pixaroma

Paint over the bad bit and let the node do the fiddly geometry

By pixaroma·Created 5 months ago·Updated 4 days ago· 357
Inpaint Crop Pixaroma
  • image
  • mask
  • image
  • mask
  • crop_info
  • width
  • height
size_modekeep shape (long side)
target1024
multiple8
context_px24
mask_grow4
mask_blur4
softness16
blend_modemask
invert_maskfalse

Inpaint Crop Pixaroma is the setup half of a crop-and-stitch inpaint, and it exists to kill the fiddliest part of traditional inpainting: all the geometry. You paint over the thing you want the AI to redo, and the node figures out a clean, model-friendly crop around it. No measuring, no manual masking math, no "wait, why is my latent a weird size."

The old way goes like this: mask the bad region, crop it, pad it to a multiple of 8, resize it toward your model's happy resolution, wire the mask into SetLatentNoiseMask, run your sampler, then painstakingly paste the result back. This node collapses the front half of that into one editor. Open the fullscreen editor, brush the area you want changed (with erase, invert, an adjustable brush size, and scroll-to-zoom plus Space-drag to pan), and the node automatically finds the box around your mask, adds a context margin, and crops a model-friendly piece - sized to a multiple of 8 and scaled toward your target so even a tiny masked spot gets enough pixels to render sharply.

Why masked inpainting is still worth it

Here's the honest framing: since late 2024, whole-image edit models (Flux Kontext, Qwen-Image-Edit, Flux 2 Klein) have taken over most of what people used to inpaint, and they're better at it for one-shot edits. But they regenerate the whole frame, so everything outside your edit comes back close-but-not-identical. Masked inpainting is still the only thing that gives you bit-identical pixels outside the mask - and cropping small and generating at full resolution is exactly how you get a 64px eye the benefit of a 1024px generation budget. If your use case is "fix this one thing and don't touch anything else," this is the right tool.

The inputs that matter

Most you can leave alone, but a few are worth knowing:

  • size_mode - keep shape (long side) scales the masked area so its long side hits the target (best quality, no stretching); force size (square) always outputs a square; free (multiple only) keeps the natural size, just rounded. Keep the default until you have a reason not to.
  • target (default 1024) - the long side (or square size) the crop aims for. Bigger crops around a small mask = more context for the model.
  • context_px (default 24) - extra surrounding pixels included on each side. This is the "room" the model gets to blend into.
  • mask_grow / mask_blur - expand the painted mask a touch and soften its edge; fixes the classic thin-seam artifact.
  • invert_mask - flips the mask so you inpaint the opposite area (swap subject and background) without a separate Invert Mask node.
  • blend_mode - mask replaces only what you painted (the safe default); whole crop replaces the entire cropped region, for when the model also relit or changed the surroundings.

It accepts an optional wired image (Load Image, VAE Decode, anything) and an optional wired mask - a mask you paint in the editor takes priority, and clearing the editor falls back to the wired one.

The outputs

image and mask (both cropped, mask grown and blurred as set) go into your inpaint conditioning - SetLatentNoiseMask into a KSampler, or into an edit model's mask input. crop_info carries the original image and where the crop came from, and feeds Inpaint Stitch Pixaroma to paste the result back. width and height hand you the exact crop size for an empty latent. The crop_info type is the same one Image Crop uses, so the two are interchangeable mid-graph.

Installing it

It ships in the ComfyUI-Pixaroma pack - ComfyUI Manager search Pixaroma, Install, restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/pixaroma/ComfyUI-Pixaroma

No model downloads for the node itself (the actual inpainting is done by whatever model you wire it into). The one house rule: after updating the pack, hard-refresh your browser tab (Ctrl+Shift+R / Cmd+Shift+R) or the editor can look broken from cached JS. The mask brush also works with a pen or tablet, which is a genuinely nice touch for anyone doing fine detail.

Category👑 Pixaroma/✂️ Resize & Crop

Inputs (11)

NameTypeDefaultDescription
size_modeCOMBOkeep shape (long side)Keep shape: scale the masked area so its long side hits the target, no stretching (best quality). Force size: always output a target x target square. Free: natural size, just rounded to the multiple.
targetINT102464–8192Target long side (keep) or square size (force), in px.
multipleCOMBO8Round the crop size to this multiple for model compatibility.
context_pxINT240–1024How many extra pixels of surrounding context to include each side.
mask_growINT40–256Expand the painted mask by this many pixels before cropping.
mask_blurINT40–256Soften the output mask edge by this many pixels for a smoother inpaint.
softnessINT160–150How far the seam feathers when Inpaint Stitch pastes the crop back. Previewed live in the mask editor.
blend_modeCOMBOmaskHow Inpaint Stitch pastes the result back. 'mask': only the area you painted is replaced - the rest of the crop keeps the original (the normal inpaint, the safe default). 'whole crop': the entire cropped region is replaced with the model's version (use when the model also relit / changed the surroundings, or for an img2img-style pass over the whole crop). Previewed live in the mask editor.
invert_maskBOOLEANfalseFlip the mask so the inpaint targets the OPPOSITE area (swap subject and background). Works on a wired mask or a painted one - a built-in alternative to an Invert Mask node. No effect if no mask is connected.
imageoptIMAGEWire any upstream IMAGE here to inpaint it (Load Image, VAE Decode, anything). You can also drag-drop or paste an image onto the node body - those load it directly and disconnect this wire.
maskoptMASKOptional mask of the area to inpaint (e.g. a transparent PNG's alpha, or any MASK output). It is used as-is whenever you have not painted a mask in the editor - so clearing the editor falls back to this wired mask. A mask painted in the editor takes priority.

Outputs (5)

NameTypeDescription
imageIMAGEThe cropped region, resized to the model-friendly output size.
maskMASKThe cropped mask at the same size (grown and blurred as set). Wire it into SetLatentNoiseMask / your inpaint conditioning.
crop_infoPIXAROMA_CROP_INFOCrop info for Inpaint Stitch Pixaroma - carries the original image and where the crop came from so the inpainted result can be pasted back exactly. Same type as Image Crop, so they are interchangeable.
widthINTCropped output width in pixels (for an empty latent / edit models).
heightINTCropped output height in pixels.