Nodes/ComfyUI-TextureAlchemy/Simple Inpaint Crop ⚡
ComfyUI Node

Simple Inpaint Crop ⚡

The cleanest crop-and-stitch loop in the pack

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Simple Inpaint Crop ⚡
  • image
  • mask
  • cropped_image
  • cropped_mask
  • masked_composite
  • bbox_data
  • info
padding32
invert_maskfalse

Masked inpainting's whole remaining superpower is precision: render only the pixels you changed, at full resolution, and leave everything else bit-identical. Simple Inpaint Crop is the first half of a workflow that makes that trivial. It crops to your mask, bundles the crop's position into bbox_data, and pairs with Simple Inpaint Stitch to put the result back where it belongs.

How it works

You feed it image and mask. It finds the mask's bounding box, expands it by padding (default 32 pixels - the context room around the masked region), and crops both the image and mask to that box. invert_mask flips which region counts as "the thing to crop," which you want when your mask was generated as negative space.

The output set is what makes this node nice to work with:

  • cropped_image - the tight crop you run through your sampler.
  • cropped_mask - the same crop of the mask, to feed the sampler as the inpaint condition.
  • masked_composite - the crop with the mask multiplied in, so you can eyeball exactly what's selected.
  • bbox_data - a small bundle of {x, y, width, height, original_width, original_height}. This is the glue: hand it to Simple Inpaint Stitch and the edit lands back in the right spot with zero coordinate math on your part.

Why crop at all

Because context is cheap but resolution is expensive. A 64-pixel detail inside a 2048 texture has only 64 pixels of generation budget if you sample the whole thing - crop it and that same region gets the model's full native resolution. That's the classic masked-inpainting advantage that even the instruction-editor wave hasn't taken away. Worth noting: the crop comes out at original resolution, so for a small mask you'll often upscale the crop (say to 1024²) before sampling, then let Stitch's auto-resize handle the trip back.

Installing it

In amtarr/ComfyUI-TextureAlchemy. ComfyUI Manager → search "Texture Alchemy", or:

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

Restart, then right-click → Add Node → Texture Alchemist → Inpainting → Simple. No extra dependencies or models.

Where people get burned

An empty mask makes it fall back to the full image - which is a silent surprise if you expected a crop. And if your mask is huge, the crop is huge, and you've gained nothing; crop-and-stitch is a small-region tool. The pack also prints a console banner every run, which is the author's normal logging style. One more: if you only want a crop and plan to save it standalone, don't forget the bbox travels separately - it's carried on the wire, not stamped into the PNG.

CategoryTexture Alchemist/Inpainting/Simple

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskMASK
paddingINT320–500Extra padding around mask (pixels)
invert_maskBOOLEANfalseInvert mask before processing

Outputs (5)

NameTypeDescription
cropped_imageIMAGE
cropped_maskMASK
masked_compositeIMAGE
bbox_dataBBOX_DATA
infoSTRING