my code to save image is:
var fs = require('fs');
const dialog = require('electron').remote.dialog;
var canvasBuffer = require('electron-canvas-to-buffer');
dialog.showSaveDialog({title:'Testing a save dialog',defaultPath:'image.jpg'},saveCallback);
function saveCallback(filePath) {
// as a buffer
var buffer = canvasBuffer(canvas, 'image/png')
// write canvas to file
fs.writeFile('image.png', buffer, function (err) {
throw err
})
}
I am not able to save the image drawn on the canvas
the error window shows
img.toPNG
is not a function
error.