Image Iterative Stretch Fill
Stretch the border, keep the texture
- image
- mask
- image
UC_ImageInwardEdgeFill fills a border by sampling nearest pixels inward. This one takes the idea further with a "stretch" instead of a "fill": it grabs a band of real unmasked pixels at the border and stretches them into the masked zone, repeatedly, shrinking the mask a little each pass. The result is a border extension that keeps the texture of the surrounding content - which is the thing a plain edge-repeat or a naive fill always destroys.
If you've ever outpainted and watched a sky or a wall become a smeary gradient at the seam, this is the pre-step that fixes the category of problem. Extend the border with plausible texture first, then let the model finish the job.
How it works
For each iteration it takes sample_thickness pixels (default 32) of unmasked image from the current border and stretches them into the masked area, then shrinks the mask by mask_decay_pixels (default 4) and repeats up to iterations times (default 5). The decay is what makes it "telescoping": each pass reaches a little further, so a wide border gets built up in stages instead of one giant stretch that looks like a photocopy of a single band.
stretch_axis-autostretches across the narrowest dimension of the current mask;horizontal/verticalforce a direction.edge_blend_blur(default 9) - softens the mask boundary so each stretch merges invisibly; 0 disables.
Single output: image, border extended with stretched content.
When to use which
Reach for this when the border is more than a thin sliver and you want texture continuity - cloth, foliage, brick, water. The plain inward fill is better for thin uniform bands where you don't want the extra passes. Honest trade-off: iterative stretch is slower and, on big empty regions (flat sky), it doesn't have texture to preserve - there, a simple fill or edge-pad is equally good and faster.
Installing it
ComfyUI Manager → search "ComfyUI-UtilsCollection", or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart. Pack deps are opencv-python and typing-extensions, no models. Newer-API pack - keep ComfyUI updated.
Tuning reality check: iterations × mask_decay_pixels roughly equals how deep the fill can reach. With defaults that's 5×4 = 20px of reach. If your border is 200px wide, cranking iterations to 50 is the wrong move - raise sample_thickness and mask_decay_pixels instead, or you'll spend minutes watching it grind a few pixels at a time.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| stretch_axis | COMBO | auto | 'Auto' stretches across the narrowest dimension of the current mask. |
| sample_thickness | INT | 321–512 | How many pixels of unmasked image to grab from the edges to stretch inwards. |
| edge_blend_blur | INT | 90–101 | Softens the mask boundary to seamlessly blend the stretched fill. |
| iterations | INT | 51–50 | Number of times to repeat the stretch and fill process. |
| mask_decay_pixels | INT | 40–64 | Shrinks the mask by this many pixels each iteration, creating a telescoping fill effect. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |