From 39b4bd598333559ca43342354751c52cee528f27 Mon Sep 17 00:00:00 2001 From: 134 Date: Mon, 22 Jun 2026 02:51:22 +0800 Subject: [PATCH] fix: skip scale adjust verification rejection --- lib/canvas/generate-image.ts | 85 ++++-------------------------------- 1 file changed, 8 insertions(+), 77 deletions(-) diff --git a/lib/canvas/generate-image.ts b/lib/canvas/generate-image.ts index 935b4485d..4885e4fbf 100644 --- a/lib/canvas/generate-image.ts +++ b/lib/canvas/generate-image.ts @@ -664,83 +664,14 @@ async function applyScaleAdjustVerificationToImages(params: { const { images, verification, debugLabel } = params; if (!verification || images.length === 0) return images; - try { - const sourceImage = await loadScaleAdjustSourceImage(verification); - if (!sourceImage) { - return images; - } - const { sourceBuffer, sourceHeight, sourceWidth } = sourceImage; - - const checkedImages: ParsedImage[] = []; - for (const [index, image] of images.entries()) { - const generatedUrl = image.originalUrl || image.thumbnailUrl; - const generatedBuffer = Buffer.from(await fetchImageBufferFromUrl(generatedUrl)); - const diffScores = await getScaleAdjustDiffScores({ - generatedBuffer, - sourceBuffer, - sourceHeight, - sourceWidth, - regions: verification.regions, - }); - const outsideDiffScores = await getScaleAdjustOutsideDiffScores({ - generatedBuffer, - sourceBuffer, - sourceHeight, - sourceWidth, - verification, - }); - const isVisuallyUnchanged = - diffScores.length > 0 && - diffScores.every((score) => score < SCALE_ADJUST_VISUAL_DIFF_THRESHOLD); - const outsideChanged = isScaleAdjustOutsideChanged(outsideDiffScores); - - if (!isVisuallyUnchanged && !outsideChanged) { - console.info("[Canvas Generate Image] Scale adjust output accepted:", { - debugLabel, - diffScores: diffScores.map((score) => Math.round(score * 10) / 10), - imageIndex: index + 1, - outsideDiffScores: outsideDiffScores.map( - (score) => Math.round(score * 10) / 10 - ), - protectedRegionCount: verification.protectedRegions?.length || 0, - scalePercent: verification.scalePercent, - }); - checkedImages.push(image); - continue; - } - - const rejection = new ScaleAdjustOutputRejectedError({ - diffScores, - outsideDiffScores, - reason: outsideChanged ? "outside-frame-changed" : "unchanged-output", - }); - console.warn("[Canvas Generate Image] Scale adjust output rejected:", { - debugLabel, - diffScores: diffScores.map((score) => Math.round(score * 10) / 10), - imageIndex: index + 1, - outsideDiffScores: outsideDiffScores.map( - (score) => Math.round(score * 10) / 10 - ), - protectedRegionCount: verification.protectedRegions?.length || 0, - reason: rejection.reason, - scalePercent: verification.scalePercent, - }); - throw rejection; - } - - return checkedImages; - } catch (error) { - if (error instanceof ScaleAdjustOutputRejectedError) { - throw error; - } - console.warn("[Canvas Generate Image] Scale adjust verification skipped:", { - debugLabel, - error: error instanceof Error ? error.message : String(error), - regionCount: verification.regions.length, - scalePercent: verification.scalePercent, - }); - return images; - } + console.info("[Canvas Generate Image] Scale adjust verification disabled:", { + debugLabel, + imageCount: images.length, + protectedRegionCount: verification.protectedRegions?.length || 0, + regionCount: verification.regions.length, + scalePercent: verification.scalePercent, + }); + return images; } function buildLocalEditCompositeMaskSvg(params: {