scijs / get-pixels

Reads an image into an ndarray
MIT License
543 stars 108 forks source link

Path Error on Buffer #51

Closed fatihtelis closed 4 months ago

fatihtelis commented 3 years ago

Hi,

On getPixels function, url param may also be a Buffer. But, on dom-pixels.js Line 120, it tries to get the extension from url.

var ext = path.extname(url)

When you send a Buffer as argument, path.extname function gives an error since url is not a string.

There has to be control whether the url is a path or not. typeof url or Buffer.isBuffer(url) may be used here.

var ext = typeof url === "string" ? path.extname(url) : null;

Otherwise, path.extname does not accept Buffer as an argument.

yelhouti commented 3 years ago

Same issue here...

johnnyshankman commented 2 years ago

+1 Can't get this to work.

My console log says I'm passing in

<Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 48 00 48 00 00 ff db 00 43 00 08 06 06 07 06 05 08 07 07 07 09 09 08 0a 0c 14 0d 0c 0b 0b 0c 19 12 13 0f ... 508 more bytes>

But then I get

Bad pixels path