Open jimmywarting opened 3 years ago
Just did some testing on this, and didn't see any performance improvements. It might have been my implementation, but I actually saw a 100ms increase. You still need canvas, since canvas-to-buffer doesn't include tooling for createCanvas
or loadImage
. The latter could be abstracted away using svgs, but the former will always be needed. eg:
const { createCanvas, loadImage } = require("canvas");
const Frame = require("canvas-to-buffer");
const canvas = createCanvas(this.size, this.size);
// ... all the existing code
// Output
const frame = new Frame(canvas);
return frame.toBuffer();
Drop this lib https://github.com/andyruwruw/chess-image-generator/blob/e885ef1ceecb4364fdf2aeb5758604e6d3b044ee/src/chess-image-generator.js#L5
it will work much faster