mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
Reenable rotate
This commit is contained in:
@@ -154,35 +154,38 @@ export const preprocessors = {
|
|||||||
dither: 1.0,
|
dither: 1.0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// rotate: {
|
rotate: {
|
||||||
// name: "Rotate",
|
name: 'Rotate',
|
||||||
// description: "Rotate image",
|
description: 'Rotate image',
|
||||||
// instantiate: async () => {
|
instantiate: async () => {
|
||||||
// return async (buffer, width, height, { degrees }) => {
|
return async (buffer, width, height, { numRotations }) => {
|
||||||
// const sameDimensions = degrees == 0 || degrees == 180;
|
const degrees = (numRotations * 90) % 360;
|
||||||
// const size = width * height * 4;
|
const sameDimensions = degrees == 0 || degrees == 180;
|
||||||
// const { instance } = await WebAssembly.instantiate(
|
const size = width * height * 4;
|
||||||
// await fsp.readFile(pathify(rotateWasm))
|
const { instance } = await WebAssembly.instantiate(
|
||||||
// );
|
await fsp.readFile(pathify(rotateWasm)),
|
||||||
// const { memory } = instance.exports;
|
);
|
||||||
// const pagesNeeded = Math.ceil(
|
const { memory } = instance.exports;
|
||||||
// (size * 2 - memory.buffer.byteLength) / (64 * 1024)
|
const additionalPagesNeeded = Math.ceil(
|
||||||
// );
|
(size * 2 - memory.buffer.byteLength + 8) / (64 * 1024),
|
||||||
// memory.grow(pagesNeeded);
|
);
|
||||||
// const view = new Uint8ClampedArray(memory.buffer);
|
if (additionalPagesNeeded > 0) {
|
||||||
// view.set(buffer, 8);
|
memory.grow(additionalPagesNeeded);
|
||||||
// instance.exports.rotate(width, height, degrees);
|
}
|
||||||
// return new ImageData(
|
const view = new Uint8ClampedArray(memory.buffer);
|
||||||
// new Uint8ClampedArray(view.slice(size + 8, size * 2 + 8)),
|
view.set(buffer, 8);
|
||||||
// sameDimensions ? width : height,
|
instance.exports.rotate(width, height, degrees);
|
||||||
// sameDimensions ? height : width
|
return new ImageData(
|
||||||
// );
|
new Uint8ClampedArray(view.slice(size + 8, size * 2 + 8)),
|
||||||
// };
|
sameDimensions ? width : height,
|
||||||
// },
|
sameDimensions ? height : width,
|
||||||
// defaultOptions: {
|
);
|
||||||
// numRotations: 0
|
};
|
||||||
// }
|
},
|
||||||
// }
|
defaultOptions: {
|
||||||
|
numRotations: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const codecs = {
|
export const codecs = {
|
||||||
|
|||||||
Reference in New Issue
Block a user