fix: normalize scale adjust verification samples

This commit is contained in:
134 2026-06-19 23:15:46 +08:00
parent b6296d4022
commit c0e16a354f

View File

@ -361,18 +361,21 @@ async function getScaleAdjustRegionSample(params: {
sourceHeight: number;
region: CanvasLocalEditCompositeRegion;
}) {
const normalizedBuffer = await sharp(params.buffer, { failOn: "none" })
.rotate()
.resize(params.sourceWidth, params.sourceHeight, {
fit: "cover",
position: "center",
})
.png({ compressionLevel: 6 })
.toBuffer();
const box = rectToPixelBox({
region: params.region,
width: params.sourceWidth,
height: params.sourceHeight,
});
return sharp(params.buffer, { failOn: "none" })
.rotate()
.resize(params.sourceWidth, params.sourceHeight, {
fit: "cover",
position: "center",
})
return sharp(normalizedBuffer, { failOn: "none" })
.extract(box)
.resize(SCALE_ADJUST_DIFF_SAMPLE_SIZE, SCALE_ADJUST_DIFF_SAMPLE_SIZE, {
fit: "fill",