image-js / image-js-typescript

Temporary repository to work on the migration of image-js to TypeScript
https://image-js.github.io/image-js-typescript/
MIT License
4 stars 5 forks source link

Loading image from dataURL (url) #297

Open lpatiny opened 1 year ago

lpatiny commented 1 year ago

I'm using a webcam and I have a code like:

    const imageSrc = webcamRef.current.getScreenshot();
    const response = await fetch(imageSrc);
    const arrayBuffer = await response.arrayBuffer();
    const image = decode(new Uint8Array(arrayBuffer));

I didn't know this trick to convert a dataURL to arraybuffer.

Should there be a static method readURL in image-js that does allows a URL or dataURL ?

targos commented 1 year ago

I suggest we implement fetchURL which uses the fetch API internally (in node and the browser).