fix: upload normalized source for fal scale edit

This commit is contained in:
134 2026-07-08 20:41:19 +08:00
parent ff71e3935c
commit 3aa031a4e4

View File

@ -3984,6 +3984,15 @@ async function createScaleAdjustPatchReference(params: {
return uploadScaleAdjustPrepAsset(filename, buffer);
};
if (params.fullFrameReferenceOnly && structureLockAppliedRef.value) {
const sourceFullUploadBuffer = await sharp(sourceBuffer, { failOn: "none" })
.rotate()
.flatten({ background: "#ffffff" })
.jpeg({ quality: 94, mozjpeg: true })
.toBuffer();
const sourceFullUpload = await uploadScaleAdjustPrepAsset(
`canvas-scale-adjust-full-source-${suffix}.jpg`,
sourceFullUploadBuffer
);
const targetDraftFullUpload = await uploadScaleAdjustPrepAsset(
`canvas-scale-adjust-full-target-draft-${suffix}.jpg`,
targetDraftUploadBuffer
@ -4042,7 +4051,7 @@ async function createScaleAdjustPatchReference(params: {
productLockFalEditMaskUrl: productLockFalEditMaskUpload?.url || null,
productLockOverlayUrl: productLockOverlayUpload?.url || null,
productLockProtectMaskUrl: productLockProtectMaskUpload?.url || null,
sourceCropUrl: sourceImageUrl || fullFrameFallbackUrl,
sourceCropUrl: sourceFullUpload?.url || sourceImageUrl || fullFrameFallbackUrl,
structureLockedDraft: structureLockAppliedRef.value,
targetDraftFullUrl: fullFrameFallbackUrl,
targetDraftUrl: fullFrameFallbackUrl,
@ -5695,12 +5704,12 @@ export async function POST(request: NextRequest) {
? useScaleAdjustProductLockComposite
? useScaleAdjustProductLockMaskEdit
? [
sourceImageUrl,
scaleAdjustPatchReference.sourceCropUrl,
...scaleAdjustCropReferenceImageUrls,
...manualRegionReferenceImageUrls,
]
: [
sourceImageUrl,
scaleAdjustPatchReference.sourceCropUrl,
scaleAdjustPatchReference.backgroundPlateFullUrl as string,
...scaleAdjustCropReferenceImageUrls,
...manualRegionReferenceImageUrls,