Skip to content

Loading image from dataURL (url) #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lpatiny opened this issue Apr 17, 2023 · 2 comments · Fixed by #482
Closed

Loading image from dataURL (url) #297

lpatiny opened this issue Apr 17, 2023 · 2 comments · Fixed by #482
Assignees

Comments

@lpatiny
Copy link
Member

lpatiny commented Apr 17, 2023

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
Copy link
Member

targos commented Apr 17, 2023

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

@stropitek
Copy link
Contributor

@EscapedGibbon you can do this and update the documentation: https://image-js-docs.pages.dev/docs/Getting%20started/#loading-your-first-image-in-browser to use the new loading method.

@EscapedGibbon EscapedGibbon linked a pull request Mar 25, 2025 that will close this issue
EscapedGibbon added a commit that referenced this issue Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants