fix: simplify fal scale adjust guide marks
This commit is contained in:
parent
2cccac34ff
commit
ee403bff11
@ -1380,20 +1380,8 @@ function buildScaleAdjustFalPhotoGuideSvg(params: {
|
|||||||
const { width, height, regions, scalePercent } = params;
|
const { width, height, regions, scalePercent } = params;
|
||||||
const minSide = Math.max(1, Math.min(width, height));
|
const minSide = Math.max(1, Math.min(width, height));
|
||||||
const strokeWidth = Math.max(3, Math.round(minSide * 0.005));
|
const strokeWidth = Math.max(3, Math.round(minSide * 0.005));
|
||||||
const fontSize = Math.max(16, Math.round(minSide * 0.022));
|
|
||||||
const labelPadX = Math.round(fontSize * 0.48);
|
|
||||||
const labelHeight = Math.round(fontSize * 1.35);
|
|
||||||
const currentColor = "#00b8d4";
|
const currentColor = "#00b8d4";
|
||||||
const finalColor = "#2563eb";
|
const finalColor = "#2563eb";
|
||||||
const label = (text: string, x: number, y: number, color: string) => {
|
|
||||||
const labelWidth = Math.round(text.length * fontSize * 0.74 + labelPadX * 2);
|
|
||||||
const left = clamp(x, 6, Math.max(6, width - labelWidth - 6));
|
|
||||||
const top = clamp(y, 6, Math.max(6, height - labelHeight - 6));
|
|
||||||
return `
|
|
||||||
<rect x="${left}" y="${top}" width="${labelWidth}" height="${labelHeight}" rx="${Math.round(labelHeight * 0.22)}" fill="${color}" opacity="0.92" />
|
|
||||||
<text x="${left + labelPadX}" y="${top + Math.round(labelHeight * 0.68)}" fill="#ffffff" font-size="${fontSize}" font-family="Arial, Helvetica, sans-serif" font-weight="800">${escapeXml(text)}</text>
|
|
||||||
`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const regionSvg = regions
|
const regionSvg = regions
|
||||||
.map((region) => {
|
.map((region) => {
|
||||||
@ -1407,8 +1395,6 @@ function buildScaleAdjustFalPhotoGuideSvg(params: {
|
|||||||
<rect x="${target.left}" y="${target.top}" width="${target.width}" height="${target.height}" rx="${radius}" fill="${finalColor}" opacity="0.14" />
|
<rect x="${target.left}" y="${target.top}" width="${target.width}" height="${target.height}" rx="${radius}" fill="${finalColor}" opacity="0.14" />
|
||||||
<rect x="${source.left}" y="${source.top}" width="${source.width}" height="${source.height}" rx="${radius}" fill="none" stroke="${currentColor}" stroke-width="${strokeWidth}" stroke-dasharray="${strokeWidth * 2} ${strokeWidth * 1.4}" opacity="0.95" />
|
<rect x="${source.left}" y="${source.top}" width="${source.width}" height="${source.height}" rx="${radius}" fill="none" stroke="${currentColor}" stroke-width="${strokeWidth}" stroke-dasharray="${strokeWidth * 2} ${strokeWidth * 1.4}" opacity="0.95" />
|
||||||
<rect x="${target.left}" y="${target.top}" width="${target.width}" height="${target.height}" rx="${radius}" fill="none" stroke="${finalColor}" stroke-width="${Math.max(3, Math.round(strokeWidth * 1.25))}" opacity="0.98" />
|
<rect x="${target.left}" y="${target.top}" width="${target.width}" height="${target.height}" rx="${radius}" fill="none" stroke="${finalColor}" stroke-width="${Math.max(3, Math.round(strokeWidth * 1.25))}" opacity="0.98" />
|
||||||
${label(`CURRENT ${region.index}`, source.left + strokeWidth, source.top + strokeWidth, currentColor)}
|
|
||||||
${label(`FINAL ${region.index}`, target.left + strokeWidth, target.top + strokeWidth, finalColor)}
|
|
||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
.join("");
|
.join("");
|
||||||
@ -1655,11 +1641,11 @@ function buildScaleAdjustCoordinatePrompt(
|
|||||||
"Interior furniture photo edit.",
|
"Interior furniture photo edit.",
|
||||||
`Return one realistic photo with the same camera frame and pixel size as input image 1: ${sourceSize.width} x ${sourceSize.height} px.`,
|
`Return one realistic photo with the same camera frame and pixel size as input image 1: ${sourceSize.width} x ${sourceSize.height} px.`,
|
||||||
"Input image 1 is the source photo. Input image 2 is a marked copy of the source photo for location guidance only and should not appear in the final photo.",
|
"Input image 1 is the source photo. Input image 2 is a marked copy of the source photo for location guidance only and should not appear in the final photo.",
|
||||||
"The guide labels CURRENT as the existing furniture box and FINAL as the requested final footprint.",
|
"In the guide, the cyan dashed box marks the existing furniture area and the blue solid box marks the requested final footprint.",
|
||||||
"Resize only the furniture subject indicated by each current box. Keep the camera, room layout, walls, windows, floor, rug, sofa, lamp, text, and background stable.",
|
"Resize only the furniture subject indicated by each current box. Keep the camera, room layout, walls, windows, floor, rug, sofa, lamp, text, and background stable.",
|
||||||
"Preserve the furniture identity, material, perspective, objects on top, and natural aspect ratio.",
|
"Preserve the furniture identity, material, perspective, objects on top, and natural aspect ratio.",
|
||||||
"For a smaller final footprint, show the furniture smaller and blend newly visible floor, rug, wall, window area, shadow, and background around it naturally. For a larger final footprint, scale the same furniture proportionally with natural edges and contact shadows.",
|
"For a smaller final footprint, show the furniture smaller and blend newly visible floor, rug, wall, window area, shadow, and background around it naturally. For a larger final footprint, scale the same furniture proportionally with natural edges and contact shadows.",
|
||||||
"Return a clean photo without guide marks, labels, boxes, arrows, overlays, patch edges, color mismatch, or full-frame zoom.",
|
"Return a clean photo without guide marks, boxes, arrows, overlays, patch edges, color mismatch, or full-frame zoom.",
|
||||||
cropLines ? `${cropLines}` : "",
|
cropLines ? `${cropLines}` : "",
|
||||||
"",
|
"",
|
||||||
"Region instructions:",
|
"Region instructions:",
|
||||||
@ -2054,7 +2040,7 @@ export async function POST(request: NextRequest) {
|
|||||||
scaleAdjustPromptStrategy: isScaleAdjustOperation
|
scaleAdjustPromptStrategy: isScaleAdjustOperation
|
||||||
? useScaleAdjustCoordinateGuide
|
? useScaleAdjustCoordinateGuide
|
||||||
? useFalScaleAdjustCoordinatePrompt
|
? useFalScaleAdjustCoordinatePrompt
|
||||||
? "fal-safe-marked-photo-guide-no-old-crop-v43-one-shot"
|
? "fal-safe-marked-photo-box-guide-no-old-crop-v44-one-shot"
|
||||||
: "same-name-zoomed-coordinate-map-no-old-crop-v42-one-shot"
|
: "same-name-zoomed-coordinate-map-no-old-crop-v42-one-shot"
|
||||||
: "locked-plate-semantic-target-map-no-old-crop-v15"
|
: "locked-plate-semantic-target-map-no-old-crop-v15"
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user