When I am generating image on the server side & getting base64 image string.
Which I want to send as image object. It is working properly with node-canvas by creating image stream.
let stream = this.canvas.jpegStream({progressive: true});
this.res.writeHead(200, {
'Content-Type': 'image/jpeg'
});
stream.on('data', (chunk) => {
this.res.write(chunk);
});
stream.on('end', () => {
this.res.end();
});
// Working perfectly...!
But when I am using fabric.js it was returning direct base64 image instead of base64 stream like node-canvas. When I was sending base64 as response the image is coming blank.
this.res.writeHead(200, {
'Content-Type': 'image/png'
});
this.res.write(this.fabricCanvas.toDataURL());
this.res.end();