Return Uint8ClampedArray in resize operation

This commit is contained in:
ergunsh
2021-06-08 20:28:22 +02:00
parent a18ed360eb
commit 5707eeff41
7 changed files with 40 additions and 21 deletions

View File

@@ -163,19 +163,17 @@ export const preprocessors = {
target_width: width,
target_height: height,
}));
const resizeResult = resize.resize(
buffer,
input_width,
input_height,
width,
height,
resizeNameToIndex(method),
premultiply,
linearRGB,
);
return new ImageData(
// ImageData does not accept Uint8Array so we convert it to a clamped array
new Uint8ClampedArray(resizeResult),
resize.resize(
buffer,
input_width,
input_height,
width,
height,
resizeNameToIndex(method),
premultiply,
linearRGB,
),
width,
height,
);