fix: use cutout drafts for scale shrink

This commit is contained in:
134 2026-07-04 12:21:17 +08:00
parent 392a03a2ed
commit 04f440574b

View File

@ -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
? `<rect x="${innerLeft}" y="${innerTop}" width="${innerRight - innerLeft}" height="${innerBottom - innerTop}" rx="${Math.max(4, Math.round(radius * 0.65))}" ry="${Math.max(4, Math.round(radius * 0.65))}" fill="${fill}" fill-opacity="0.08" filter="url(#soft-wash-${index})" />`
? `<rect x="${innerLeft}" y="${innerTop}" width="${innerRight - innerLeft}" height="${innerBottom - innerTop}" rx="${Math.max(4, Math.round(radius * 0.65))}" ry="${Math.max(4, Math.round(radius * 0.65))}" fill="${fill}" fill-opacity="0.18" filter="url(#soft-wash-${index})" />`
: "";
return `<rect x="${left}" y="${top}" width="${rectWidth}" height="${rectHeight}" rx="${radius}" ry="${radius}" fill="${fill}" fill-opacity="${SCALE_ADJUST_LAYOUT_GUIDE_WASH_OPACITY}" filter="url(#soft-wash-${index})" />${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