save html5 canvas element to file using webos

笑着哭i 提交于 2019-12-01 12:40:32

data is a string which starts with data:image/png;base64, and the rest is the data in base64.

  1. Remove data:image/png;base64, from data
  2. Convert it from base64 to binary
  3. Save that binary buffer to file

Code

var buff = new Buffer(data.substr('data:image/png;base64,'.length), 'base64');
...
fs.write(id, buff, 0, buff.length, 0, function(...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!