Closed
Description
I am using jsdom and node-canvas to run frontend html canvas code within node js, one of my script files has the line
canvas.toDataURL('image/jpeg',{quality:1},function(){})
the third parameter is because node-canvas demands 3 parameters over here at line 301 in canvas.js
else if ('image/jpeg' === type) {
if (undefined === fn) {
throw new Error('Missing required callback function for format "image/jpeg"');
}
var stream = this.jpegStream(opts);
// note that jpegStream is synchronous
var buffers = [];
stream.on('data', function (chunk) {
buffers.push(chunk);
});
stream.on('error', function (err) {
fn(err);
});
stream.on('end', function() {
var result = 'data:image/jpeg;base64,' + Buffer.concat(buffers).toString('base64');
fn(null, result);
});
}
but jsdom passes only two arguments to this, and it might not be their fault since the official frontend canvas.toDataURL is supposed to take only 2 arguments.
I need to generate pdfs using jpg images generated by canvas in node. Would appreciate any help