fix: clip product lock repairs to soft mask

This commit is contained in:
134 2026-07-07 21:30:57 +08:00
parent 961ce30500
commit 15fc9ebea9
2 changed files with 28 additions and 12 deletions

View File

@ -5934,8 +5934,7 @@ export async function POST(request: NextRequest) {
scaleAdjustPostCompositeApplied:
Boolean(scaleAdjustPatchReference) &&
(!useScaleAdjustFullFrameStructurePatch ||
(useScaleAdjustProductLockComposite &&
!useScaleAdjustProductLockDirectMaskPlate)),
useScaleAdjustProductLockComposite),
scaleAdjustUsesFullFrameOutput:
isScaleAdjustOperation &&
(!scaleAdjustPatchReference || useScaleAdjustFullFrameStructurePatch),
@ -5986,18 +5985,18 @@ export async function POST(request: NextRequest) {
: undefined,
referenceImages,
scaleAdjustPatchComposite:
useScaleAdjustProductLockComposite && !useScaleAdjustProductLockDirectMaskPlate
useScaleAdjustProductLockComposite
? {
diffAlphaCutoff: 18,
diffAlphaMultiplier: 2.6,
diffCompareBlurPx: 1.1,
diffHighThreshold: 64,
diffLowThreshold: 20,
featherMaxPx: 34,
featherMinPx: 8,
featherRatio: 0.015,
featherMaxPx: useScaleAdjustProductLockDirectMaskPlate ? 72 : 34,
featherMinPx: useScaleAdjustProductLockDirectMaskPlate ? 18 : 8,
featherRatio: useScaleAdjustProductLockDirectMaskPlate ? 0.026 : 0.015,
generatedFrame: "full",
maskMode: "diff",
maskMode: useScaleAdjustProductLockDirectMaskPlate ? "workspace" : "diff",
regions: scaleAdjustPatchCompositeRegions,
sourceImageUrl,
clipMaskImageUrl: scaleAdjustProductLockRepairClipMaskUrl,

View File

@ -3059,6 +3059,13 @@ async function applyScaleAdjustPatchCompositeToImages(params: {
touchesTop,
width: workspaceBox.width,
});
const staticPatchMaskRaw = staticPatchMask
? await normalizeAlphaMaskToRaw({
height: workspaceBox.height,
maskBuffer: staticPatchMask,
width: workspaceBox.width,
})
: null;
const regionClipPatchMask = maskRegionBoxes?.length
? buildScaleAdjustPatchCompositeMaskSvg({
featherPx,
@ -3177,11 +3184,21 @@ async function applyScaleAdjustPatchCompositeToImages(params: {
imageBuffer: resizedGeneratedBuffer,
width: workspaceBox.width,
})
: await sharp(resizedGeneratedBuffer, { failOn: "none" })
.ensureAlpha()
.composite([{ input: patchMask, blend: "dest-in" }])
.png({ compressionLevel: 6 })
.toBuffer();
: activeClipPatchMaskRaw || staticPatchMaskRaw
? await applyRawAlphaToImage({
alphaMaskRaw:
activeClipPatchMaskRaw && staticPatchMaskRaw
? multiplyAlphaMasks(staticPatchMaskRaw, activeClipPatchMaskRaw)
: activeClipPatchMaskRaw || staticPatchMaskRaw!,
height: workspaceBox.height,
imageBuffer: resizedGeneratedBuffer,
width: workspaceBox.width,
})
: await sharp(resizedGeneratedBuffer, { failOn: "none" })
.ensureAlpha()
.composite([{ input: patchMask, blend: "dest-in" }])
.png({ compressionLevel: 6 })
.toBuffer();
const mergedBuffer = await sharp(sourceBuffer, { failOn: "none" })
.ensureAlpha()
.composite([