Nodes/ComfyUI-UtilsCollection/Image Iterative Stretch Fill
ComfyUI Node

Image Iterative Stretch Fill

Stretch the border, keep the texture

By silveroxides·Created 2 months ago·Updated about 7 hours ago· 24
Image Iterative Stretch Fill
  • image
  • mask
  • image
stretch_axisauto
sample_thickness32
edge_blend_blur9
iterations5
mask_decay_pixels4

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 - auto stretches across the narrowest dimension of the current mask; horizontal/vertical force 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.

Categoryadvanced/image

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
maskMASK
stretch_axisCOMBOauto'Auto' stretches across the narrowest dimension of the current mask.
sample_thicknessINT321–512How many pixels of unmasked image to grab from the edges to stretch inwards.
edge_blend_blurINT90–101Softens the mask boundary to seamlessly blend the stretched fill.
iterationsINT51–50Number of times to repeat the stretch and fill process.
mask_decay_pixelsINT40–64Shrinks the mask by this many pixels each iteration, creating a telescoping fill effect.

Outputs (1)

NameTypeDescription
imageIMAGE