ApeironTsuka / node-webpmux

A mostly 1:1 re-implementation of webpmux as a Node module in pure Javascript. Only thing currently missing is a command-line version.
GNU Lesser General Public License v3.0
21 stars 8 forks source link

Cannot read properties of undefined (reading 'vp8') #20

Closed nfts2me closed 1 year ago

nfts2me commented 1 year ago

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

ApeironTsuka commented 1 year ago

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.

nfts2me commented 1 year ago

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.

ApeironTsuka commented 1 year ago

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.