Nodes/ComfyUI-TextureAlchemy/Inpaint Crop Extractor (Advanced)
ComfyUI Node

Inpaint Crop Extractor (Advanced)

Inpaint at full resolution by cropping to your mask

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Inpaint Crop Extractor (Advanced)
  • image
  • mask
  • cropped_image
  • masked_crop
  • cropped_mask
  • bbox_x
  • bbox_y
  • bbox_width
  • bbox_height
  • info
  • bbox_data
padding0
invert_maskfalse

The classic inpainting trap: you mask a tiny object in a big image, run the sampler, and the model spends its resolution budget on the whole canvas while your little fix comes back soft and mushy. The crop-and-stitch trick fixes that - crop the masked region out, inpaint the crop at full res, paste it back. That's the whole job of Inpaint Crop Extractor, the first half of a two-node pair (its partner is Inpaint Stitcher). It finds the bounding box of your mask, crops image and mask to it with optional padding, and hands you everything needed to reconstruct the original later.

This is the exact pattern the community standardized on when instruction-edit models like Qwen-Image-Edit started shipping: render a region at native resolution, composite it back, and keep every unmasked pixel bit-identical. The pack's source comments even reference the Qwen Edit workflow directly. If you want full-resolution detail where it matters and zero drift everywhere else, this pair is the mechanism.

How it works

The node takes your full image and mask, ensures the mask is resized to match the image, then (optionally) inverts it - handy when your mask was generated as a white background with the subject punched out. It computes the bounding box of the painted region, expands it by padding pixels (0–500), and crops image, masked crop, and mask to that box. It also returns the bbox as plain integers and as a BBOX_DATA object, so the stitcher can put things back exactly where they were.

Outputs worth knowing:

  • cropped_image - the region around your mask, what you'll feed to an inpainting sampler or edit model.
  • masked_crop - the crop with the mask applied, useful if you want a preview or a context image.
  • cropped_mask - the mask cropped to the same region, for the sampler's mask input.
  • bbox_x / bbox_y / bbox_width / bbox_height - the coordinates, wireable straight into InpaintStitcher.
  • bbox_data - a bundled bbox for nodes that accept the object type.
  • info - a human-readable summary.

The inputs that matter

  • mask - the selection. Resolution-independent; it gets resized to the image.
  • padding - the control that actually changes quality. A little padding stops the inpainted crop from being cut right at the mask edge, which is where seams form. Start at 16–32px, not 0.
  • invert_mask - flip this if your mask is inverted (white background, black subject).

Installing it

It's part of ComfyUI-TextureAlchemy. ComfyUI Manager → search "TextureAlchemy" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart and find it under Texture Alchemist → Inpainting. No pip packages, no models - this node is crop math.

Common issues

  • "My crop is tiny or huge." The bbox is driven entirely by the mask. A mask that includes stray noise (or the whole canvas, if you forgot to invert) produces a crop you didn't expect. Glance at masked_crop to sanity-check.
  • "The inpaint result has a visible edge." That's the seam - up the padding, or use Inpaint Stitcher's blend mode with a small feather to soften the boundary.
  • Crop and original resolutions disagree. The stitcher resizes the processed crop to the bbox size, but it's cleaner to keep your sampler output at the crop's dimensions and let the node confirm.

Used alone it's just a smart crop; wired to a sampler and then to Inpaint Stitcher it's the difference between mushy 64px fixes and crisp 1024px-generation-budget fixes. That's the whole argument.

CategoryTexture Alchemist/Inpainting

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskMASK
paddingINT00–500Extra padding around mask bounding box (pixels)
invert_maskBOOLEANfalseInvert the mask before processing (e.g., for white background masks)

Outputs (9)

NameTypeDescription
cropped_imageIMAGE
masked_cropIMAGE
cropped_maskMASK
bbox_xINT
bbox_yINT
bbox_widthINT
bbox_heightINT
infoSTRING
bbox_dataBBOX_DATA