Inpaint Crop Extractor (Advanced)
Inpaint at full resolution by cropping to your mask
- image
- mask
- cropped_image
- masked_crop
- cropped_mask
- bbox_x
- bbox_y
- bbox_width
- bbox_height
- info
- bbox_data
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_cropto sanity-check. - "The inpaint result has a visible edge." That's the seam - up the
padding, or use Inpaint Stitcher'sblendmode with a smallfeatherto 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.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| padding | INT | 00–500 | Extra padding around mask bounding box (pixels) |
| invert_mask | BOOLEAN | false | Invert the mask before processing (e.g., for white background masks) |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| masked_crop | IMAGE | — |
| cropped_mask | MASK | — |
| bbox_x | INT | — |
| bbox_y | INT | — |
| bbox_width | INT | — |
| bbox_height | INT | — |
| info | STRING | — |
| bbox_data | BBOX_DATA | — |