简体   繁体   English

在javascript中使用base 64创建本地图像文件

[英]Create a local image file with base 64 in javascript

我需要使用javascript在我的本地计算机上创建一个.png或.jpg等文件的图像文件,我有图像的基础64,可以这样做吗?

Yes you can do it. 是的,你可以做到。 All you need is: 所有你需要的是:

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

In Nodejs, create a buffer with base64 encoding and write the buffer to the file 在Nodejs中,使用base64编码创建缓冲区并将缓冲区写入文件

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM