fix: normalize scale adjust verification samples
This commit is contained in:
parent
b6296d4022
commit
c0e16a354f
@ -361,18 +361,21 @@ async function getScaleAdjustRegionSample(params: {
|
|||||||
sourceHeight: number;
|
sourceHeight: number;
|
||||||
region: CanvasLocalEditCompositeRegion;
|
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({
|
const box = rectToPixelBox({
|
||||||
region: params.region,
|
region: params.region,
|
||||||
width: params.sourceWidth,
|
width: params.sourceWidth,
|
||||||
height: params.sourceHeight,
|
height: params.sourceHeight,
|
||||||
});
|
});
|
||||||
|
|
||||||
return sharp(params.buffer, { failOn: "none" })
|
return sharp(normalizedBuffer, { failOn: "none" })
|
||||||
.rotate()
|
|
||||||
.resize(params.sourceWidth, params.sourceHeight, {
|
|
||||||
fit: "cover",
|
|
||||||
position: "center",
|
|
||||||
})
|
|
||||||
.extract(box)
|
.extract(box)
|
||||||
.resize(SCALE_ADJUST_DIFF_SAMPLE_SIZE, SCALE_ADJUST_DIFF_SAMPLE_SIZE, {
|
.resize(SCALE_ADJUST_DIFF_SAMPLE_SIZE, SCALE_ADJUST_DIFF_SAMPLE_SIZE, {
|
||||||
fit: "fill",
|
fit: "fill",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user