fix(inpaint): Stitch feathers the whole crop when there is no mask edge

Wiring an Image Crop (no mask) into Inpaint Stitch gave crop_info an all-zeros
mask; in mask blend-mode that resolved to alpha=0 and _blur_alpha pasted
NOTHING (result == original, inpaint lost). An all-ones mask gave a hard
rectangle. stitch_back now detects an all-zeros/all-ones resolved alpha (no
edge to soften) and falls back to the rectangle feather over the full crop, so
the edited crop is pasted with a soft seam and Softness still works. Also
covers a whole-image inpaint with nothing painted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
pixaroma
2026-06-16 14:50:48 +03:00
co-authored by Claude Opus 4.8
parent 1fab59686b
commit cad1586ec2
+12 -1
View File
@@ -536,7 +536,18 @@ def stitch_back(crop_info, image, mask, blend, blend_mode, color_match):
if blend_mode == "whole_crop":
a = _feather_alpha(a.clamp(0, 1), blend)
else:
a = _blur_alpha(a.clamp(0, 1), blend)
ac = a.clamp(0, 1)
ab = ac > 0.5
if not bool(ab.any()) or bool(ab.all()):
# No mask EDGE to soften - an Image Crop crop_info with no per-pixel mask
# (all-zeros), an all-ones mask, or a whole-image inpaint with nothing
# painted. _blur_alpha would return zeros (paste NOTHING - the inpaint is
# lost) or ones (a hard rectangle seam). Fall back to the rectangle feather
# over the full crop, so the edited crop IS pasted with a soft seam and the
# Softness slider still works for the Image Crop interop.
a = _feather_alpha(torch.ones((ch, cw), dtype=torch.float32), blend)
else:
a = _blur_alpha(ac, blend)
out = base.clone()
B = int(out.shape[0])