ApeironTsuka/node-webpmux

Cannot read properties of undefined (reading 'vp8')

Closed this issue · 3 comments

I'm having an issue with the library:

With this code:

const WebP = require('node-webpmux');
let img = new WebP.Image();
await img.load(imgBuffer);
await img.initLib();
const frameData = await img.getFrameData(img.frames[0]);

image

However, the frame has the VP8 property:
image

I should make types clearer in the readme, and probably do more checks for that. getFrameData() expects a frame index (in this case, 0) rather than the frame itself. Sorry about that. Going to fix that it doesn't throw an error.

Thank you.

I see now that it always tries to load "libwebp.wasm" from / , as least on React.
Is it possible to make it load "libwebp.wasm" from a different route or relative route?
If I don't put it on /libwebp.wasm, it crashes with a 404 error.

That's odd. It should be trying to load it from a relative path already. It first loads libwebp.js, which in turn loads ./libwebp/libwebp.js (the bindings, in a subdirectory of the module), which itself should be loading libwebp.wasm from that same directory. I'm not sure why it would be trying to load it from the root directory unless React is mangling the paths somehow.