diff --git a/app/api/canvas/local-edit/route.ts b/app/api/canvas/local-edit/route.ts index 5d94baec2..7ee9fb4b8 100644 --- a/app/api/canvas/local-edit/route.ts +++ b/app/api/canvas/local-edit/route.ts @@ -2696,13 +2696,7 @@ async function buildScaleAdjustRmbgStructureLockedComposite(params: { width: placement.sourceBox.width, }); if (!sourceEditMaskBbox) return null; - const sourceWashBaseMask = filteredSourceBbox - ? solidifyScaleAdjustStructureMask({ - box: placement.sourceBox, - mask: filteredSourceMask, - maxPanelSpanRatio: protectedPersonSide ? 0.96 : 0.9, - }) - : highConfidenceSourceMask; + const sourceWashBaseMask = sourceEditBaseMask; const sourceWashMask = dilateScaleAdjustStructureMask({ height: placement.sourceBox.height, mask: sourceWashBaseMask, @@ -4915,7 +4909,7 @@ function buildScaleAdjustProductLockBackgroundPrompt( regions: NormalizedLocalEditRegion[], scalePercent: ScaleAdjustPercent | null | undefined, sourceSize: { width: number; height: number }, - options: { maskEdit?: boolean } = {} + options: { backgroundReference?: boolean; maskEdit?: boolean } = {} ) { const regionLines = regions .map((region) => { @@ -4933,6 +4927,9 @@ function buildScaleAdjustProductLockBackgroundPrompt( options.maskEdit ? "Input image 1 is the original clean full photo. The supplied edit mask marks the old selected furniture/product footprint that must be repaired as natural background; do not edit outside the masked area." : "Input image 1 is the original clean full photo. Input image 2 is a background plate reference that removes the selected furniture/product footprint and keeps the room/person/background layout stable.", + options.maskEdit && options.backgroundReference + ? "Input image 2 is a rough background-only repair reference from the same photo. Use it only to understand that the old selected product must disappear and to infer nearby wall, curtain, floor, rug, shadow, and lighting continuity. Do not copy any flat wash, haze, patch edge, mask silhouette, or rough repaired texture from input image 2." + : "", "Important: do not draw, recreate, move, scale, duplicate, or redesign the selected furniture/product in the final image. The system will composite the locked original product pixels into the final target footprint after your background image is returned.", "Your job is only to erase the old selected furniture/product footprint, complete newly exposed wall, curtain, floor, rug, shadow, sofa edge, and background naturally, and keep the target footprint clean enough for the locked product layer to sit there.", "Preserve all non-target people exactly as foreground/background context: do not move, cover, deform, redraw, change face, change body, change hands, change legs, change clothes, or change pose.", @@ -5318,7 +5315,12 @@ export async function POST(request: NextRequest) { regions, scalePercent, { width: sourceWidth, height: sourceHeight }, - { maskEdit: useScaleAdjustProductLockMaskEdit } + { + backgroundReference: + useScaleAdjustProductLockMaskEdit && + Boolean(scaleAdjustPatchReference?.backgroundPlateFullUrl), + maskEdit: useScaleAdjustProductLockMaskEdit, + } ) : buildScaleAdjustFullFramePatchPrompt( regions, @@ -5392,6 +5394,9 @@ export async function POST(request: NextRequest) { ? useScaleAdjustProductLockMaskEdit ? [ sourceImageUrl, + ...(scaleAdjustPatchReference.backgroundPlateFullUrl + ? [scaleAdjustPatchReference.backgroundPlateFullUrl] + : []), ...scaleAdjustCropReferenceImageUrls, ...manualRegionReferenceImageUrls, ]