Nodes/ComfyUI-UtilsCollection/Image Iterative Stretch Fill (Legacy)
ComfyUI Node

Image Iterative Stretch Fill (Legacy)

Stretch the edges inward, telescoping, for holes a single fill can't handle

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

Inward Edge Fill is great at small holes, but a single pass from the edges gets smeary the moment the hole is wide. Iterative Stretch Fill (Legacy) is the answer for the long, skinny case - and for anything where you want the fill to look like it was pulled from one direction instead of blurred in. It grabs a band of pixels from the unmasked edge and stretches it across the hole, over and over, shrinking the mask a bit each round.

The mechanism is literally in the name. Each iteration it looks at the current mask, samples a thin strip of real pixels just outside the masked area (sample_thickness), and stretches that strip across the hole along the chosen axis. Then it erodes the mask by mask_decay_pixels and repeats. The result is a "telescoping" fill - the texture from the edges gets progressively dragged inward, so wide-but-shallow holes end up covered with actual texture from your image rather than a featureless smear. stretch_axis picks horizontal, vertical, or auto, which stretches along whatever dimension the mask is narrowest in.

The inputs that matter

  • image / mask - source and region.
  • stretch_axis - auto, horizontal, or vertical. Auto picks the narrowest dimension of the current mask each round, which is the right default for most holes.
  • sample_thickness - how many pixels of unmasked image to grab from the edges. Thicker samples carry more real texture in but can look repeated if the region is uniform.
  • iterations - how many stretch-and-fill passes to run. More iterations cover bigger holes but multiply the work and can stretch texture into obvious bands.
  • mask_decay_pixels - how much the mask shrinks each iteration. The telescoping driver.
  • edge_blend_blur - softens the mask boundary so each stretched band blends into the one before it.

The output

A single image with the masked region filled by directional stretching. Best for elongated holes: scratches, beams, banner text you want to vanish, sky gaps where you have real sky texture on both sides.

Installing it

Part of silveroxides/ComfyUI-UtilsCollection. Install via ComfyUI Manager (search ComfyUI-UtilsCollection) or:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection

Restart after. Dependencies are opencv-python and typing-extensions; no models. "(Legacy)" is the compat alias for the pack's canonical UC_ImageIterativeStretchFill.

Where people get burned

The default of 5 iterations with a 4-pixel decay covers a hole about 20 pixels wide with true stretching - beyond that you're asking each pass to do more than stretch. If you crank iterations to 20 on a wide hole, you'll see the texture start to band and repeat like venetian blinds; that's the moment to either raise sample_thickness or switch strategy. And on textured backgrounds, edge_blend_blur is not optional polish - without it, every iteration's boundary shows as a faint line. Leave it around 9 unless you're chasing a specific look.

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