Adam Katz
Adam Katz

Reputation: 6962

Create a local image file with base 64 in javascript

I need to use javascript to create an image file on my local computer a .png or .jpg etc file, I have the base 64 of the image, can this be done?

Upvotes: 1

Views: 377

Answers (2)

Gaurav Tendolkar
Gaurav Tendolkar

Reputation: 3

In Nodejs, create a buffer with base64 encoding and write the buffer to the file

refer - https://stackoverflow.com/a/6933413/4325568

Upvotes: 0

Przemek
Przemek

Reputation: 803

Yes you can do it. All you need is:

var img = new Image();
img.src = 'data:image/gif;base64,...';
document.body.appendChild(img);

Upvotes: 3

Related Questions