save html5 canvas element to file using webos

前端 未结 1 1341
南旧
南旧 2021-01-16 00:46

here img variable is extracted from using Open Source Png Generation code here ..
http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/ that is a

相关标签:
1条回答
  • 2021-01-16 01:40

    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(...
    
    0 讨论(0)
提交回复
热议问题