Hi,
I want to use CanvasKit as offscreen canvas replacement in browser. But it turns out for me that encodeToBytes is way too slow.
My code:
CanvasKitInit({
locateFile: (file) => '/node_modules/canvaskit-wasm/bin/' + file,
}).then((CanvasKit) => {
... reading an image here in img,. jpeg in my case
const skcanvas = CanvasKit.MakeCanvas(img.width,img.height);
make byte array and that line is super fast:
const skImage = CanvasKit.MakeImageFromEncoded(byteArray);
but
let pngBytes=skImage.encodeToBytes(CanvasKit.ImageFormat.PNG)
is extremely slow.
in comparison to normal offscreen-canvas in browser it is 7 times slower. So at the end I cannot use this fast library which kills performance at the very end of all fast image operations before.
Also webp was also not working as image format here for me ( I made npm install canvaskit-wasm)
Any idea to speed up PNG conversion here and what would be best to get webp support as well?
Thank you