Get image from automated download
I have this page which displays a render using threejs and renders it into a png and downloads it. i need that image to use it in a canvas from deno-canvas but when i download it using this package it returns this:
code where i download it:|
21 Replies
Looking at the docs of the
download
library the file
parameter is there to set the filename only. You're passing a full absolute path into that. Under the hood the library seem to only append the file
parameter to their own internal path leading to the broken file path you're seeing in the error message.
You might have better luck just using builtin APIs to download a file:
this still gives an error
new file:
it does look like progress tho
@Kay ah apologies, the
file.close()
should be removed
Deleted it from my code snippet. Not sure why I added that, my brain blanked probablythat worked. only the image is not valid. the
stone-valid.png
is downloaded by me just going to the url and the stone-invalid.png
is downloaded by the code. the file sizes do not match and the invalid one does not load in any image editor/viewer![No description](https://cdn.answeroverflow.com/1213108593084342282/image.png)
marvinh’s code works for me. Are you sure the file being served is the same?
its not exactly being served. its generated. first threejs generates a cube and loads a texture from a material from the url parameters. then it generates an image and downloads it
sounds like something is wrong with how the image is generated
could be but if i just go to the page myself it works fine
this is the renderer
https://gist.github.com/phant0m2290/bf07e2cf7c020879e3dfc6b8e3a089e4
It seems like you’re actually downloading the page’s source instead of the image you want.
I’m not sure you can easily/seamlessly just have Deno save the file from the browser JavaScript code.
ahh ye when i opened the file i do indeed see the html
But note that you can just run that code on Deno itself if you use the right tools, instead of having it run on a browser.
I guess Three.js might not be possible, actually. 🤔
yhea only i coudnt find a local kind of version of threejs or something like it
If you just want an isometric image, you could create it without Three.js.
how do you mean?