0

Suppose I have the following code that exports a table element as a JPG using the dom-to-image library.

domtoimage.toJpeg(document.getElementById('my-node'), { quality: 0.95 })
.then(function (dataUrl) {
    var link = document.createElement('a');
    link.download = 'my-image-name.jpeg';
    link.href = dataUrl;
    link.click();
});

I'd like to save the JPG created by this code to localStorage instead of saving it on the user's device. How can this be accomplished? Thank you!

  • Does this answer your question? [How can I convert an image into Base64 string using JavaScript?](https://stackoverflow.com/questions/6150289/how-can-i-convert-an-image-into-base64-string-using-javascript) – Christopher Aug 30 '21 at 00:52

0 Answers0