Saving and image from a web page to disk without XHR?


#1

I am new to this, I’ve readed the docs already, but didn’t put hands on yet.

Is it possible to save an image on the webpage to disk without XHR it?

Thanks in advance


#2

I realise you’ve said that you don’t want to use XHR, but the way I handle downloads is over XHR and then I save using Node’s fs.

As far as I’m aware, the only other ‘baked in’ ways of doing this would be drawing to a canvas and reading the data from that and writing that to fs or using something over kill such as the Node dgram module.

There might be npm modules out there that do what you’re after, but I don’t think you’ll find anything that loads an image that’s already loaded in the browser, nor anything that is technically any better than an XHR.


#3

That’s what I wanted, to get the image already loaded in the browser.
It would be more efficient if I can get the image already loaded.

If I load google.com I want to get the already loaded image logo in the browser to fs.


#4

You could do it the other way, AJAX the image, base64 encode it and plug it where the image should go. But that’d only really work if you already have the HTML in the app to plug the image into, which may be something you’re after, but doesn’t seem to fit the example you’ve given.

I realise it’s inconvenient, but it seems to me that sticking the loaded image into a canvas and reading the data from that is the only way to do it without another call of some form.