From 04f440574b1d83e1b42b9f5bbe128402ddbffb0e Mon Sep 17 00:00:00 2001 From: 134 Date: Sat, 4 Jul 2026 12:21:17 +0800 Subject: [PATCH] fix: use cutout drafts for scale shrink --- app/api/canvas/local-edit/route.ts | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/app/api/canvas/local-edit/route.ts b/app/api/canvas/local-edit/route.ts index 7b61dc008..0e13e4003 100644 --- a/app/api/canvas/local-edit/route.ts +++ b/app/api/canvas/local-edit/route.ts @@ -107,7 +107,7 @@ const SCALE_ADJUST_CROP_MAX_EDGE = 1536; const SCALE_ADJUST_PATCH_WORKSPACE_MIN_MARGIN = 0.045; const SCALE_ADJUST_PATCH_WORKSPACE_MAX_MARGIN = 0.18; const SCALE_ADJUST_LAYOUT_GUIDE_WASH_COLOR = "#f5f7fb"; -const SCALE_ADJUST_LAYOUT_GUIDE_WASH_OPACITY = 0.82; +const SCALE_ADJUST_LAYOUT_GUIDE_WASH_OPACITY = 0.46; const SCALE_ADJUST_STRUCTURE_LOCK_MIN_MASK_RATIO = 0.006; const SCALE_ADJUST_STRUCTURE_LOCK_COMPONENT_MIN_RATIO = 0.00018; const SCALE_ADJUST_RMBG_MIN_ALPHA_RATIO = 0.012; @@ -1150,7 +1150,7 @@ function buildScaleAdjustSourceFootprintWashSvg(params: { const fill = formatScaleAdjustWashColor(box.background); const inner = innerRight > innerLeft + 4 && innerBottom > innerTop + 4 - ? `` + ? `` : ""; return `${inner}`; }) @@ -2583,6 +2583,28 @@ async function buildScaleAdjustVisualLayoutGuideBuffer(params: { continue; } + const shouldUseShrinkCutoutDraft = + !structureLockedDraft && + sourceRaw && + userId && + (targetWidthFactor < 0.92 || targetHeightFactor < 0.92); + const shrinkCutoutComposite = shouldUseShrinkCutoutDraft + ? await buildScaleAdjustRmbgStructureLockedComposite({ + placement, + raw: sourceRaw, + sourceBuffer, + sourceImageUrl, + sourceWidth, + userId, + }) + : null; + + if (shrinkCutoutComposite) { + subjectWashComposites.push(shrinkCutoutComposite.wash); + composites.push(shrinkCutoutComposite.overlay); + continue; + } + sourceFootprintBoxes.push({ ...placement.sourceFootprintBox, background: sourceRaw @@ -4136,7 +4158,7 @@ export async function POST(request: NextRequest) { ? scaleAdjustPatchReference ? scaleAdjustPatchReference.structureLockedDraft ? "ai-patch-workspace-structure-locked-draft-v85-one-shot" - : "ai-patch-workspace-draft-v72-strong-soft-fill-one-shot" + : "ai-patch-workspace-draft-v73-rmbg-cutout-soft-wipe-one-shot" : useFalScaleAdjustCoordinatePrompt ? "fal-safe-marked-photo-box-guide-no-old-crop-v44-one-shot" : useScaleAdjustVisualLayoutGuide