Simple Crop to Mask (with Padding) ⚡
Giving your inpaint a bit of room to breathe
- image
- mask
- cropped_image
- cropped_mask
- masked_composite
- bbox_data
- info
The simplest version of inpainting fails in a predictable way: you crop tightly to the mask, the model has zero context, and the result ignores the surrounding material. Simple Crop to Mask (with Padding) fixes that by letting you decide how much of the world around the mask comes along for the ride - and what fills the space in between.
How it works
It finds the mask's bounding box, crops the image and mask to it, then expands the canvas outward by padding pixels (default 50). The interesting part is padding_color, which controls what that expanded border contains:
black/white- solid fills, simple but they introduce a hard artificial edge the model can lean on.mirror- reflects the crop edges outward, so the border is a continuation of the texture. Usually reads the most natural.edge_extend- stretches the edge pixels, good for flat colors and gradients.from_crop- takes the border from elsewhere in the tight crop.use_image- the special one: withpad_to_squareon, it grabs a square window from the full input image centered on the mask, so you get real surrounding context instead of padding. That's the "give the model actual neighbors" mode.average- fills with the crop's average color, which keeps the border neutral.custom- any hex color you type intocustom_color.
pad_to_square expands the crop to a square canvas (using the longest dimension) - useful if your downstream model wants square inputs. And invert_mask swaps which side of the mask is "the thing."
The outputs
You get cropped_image, cropped_mask, a masked_composite (crop with the mask applied, for a quick look), plus bbox_data and an info string. The bbox bundle is what makes the sibling Simple Inpaint Stitch one wire away: crop here, edit the crop, stitch it back at these exact coordinates.
Installing it
In amtarr/ComfyUI-TextureAlchemy - ComfyUI Manager "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, no models.
Where people get burned
Solid black padding is the trap: a model that's fine inpainting on a mirror border can hallucinate against a hard black frame, and it creates a visible step when you stitch. Prefer mirror or use_image + pad_to_square when the mask is near an edge. Also, this crop keeps everything in the original resolution - if the masked region is tiny, you'll want to upscale the crop before sampling so the model gets enough pixels to work with (masked inpainting's superpower is full-res detail on a small region). The pack prints a console banner every run; that's normal.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| padding | INT | 500–500 | Padding in pixels (expands canvas) |
| pad_to_square | BOOLEAN | false | Expand to square canvas (uses longest dimension) |
| padding_color | COMBO | black | use_image (with pad to square): square crop from the full input, centered on the mask. Other: from_crop/edge/mirror from tight crop; black/white/average/custom = solid/avg |
| custom_color | STRING | #000000 | Hex color for custom padding (e.g., #FF5733) |
| invert_mask | BOOLEAN | false | Invert mask (swap black/white) |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |
| cropped_mask | MASK | — |
| masked_composite | IMAGE | — |
| bbox_data | BBOX_DATA | — |
| info | STRING | — |