How to save HTML5 canvas data to file?

JavascriptWeb DevelopmentFront End Scripts

Use PNGStream to save HTML5 canvas to file.

var f = require('fs')
, out = f.createWriteStream(__dirname + '/text.png')
, stream = canvas.pngStream();
stream.on('data', function(chunk){
   out.write(chunk);
});
stream.on('end', function(){
   console.log(‘PNG Saved successfully!’);
});
raja
Published on 05-Apr-2018 13:11:26
Advertisements