I have an issue when load svg ( with base64 image inside ) file using function loadImage I get exception:
GdkPixbuf-CRITICAL **: 13:03:49.842: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
Here is my code & test svg file:
const fs = require('fs');
const { createCanvas, loadImage } = require('canvas');
async function nodeCanvasTest() {
console.log('starting...');
const canvas = createCanvas(400, 200);
const ctx = canvas.getContext('2d');
image = await loadImage('./input.svg');
ctx.drawImage(image, 0, 0);
var stream = canvas.createPNGStream();
stream.pipe(fs.createWriteStream('output.png'));
console.log('completed');
}
nodeCanvasTest();
svg file:
https://github.com/Automattic/node-canvas/files/4774170/input.svg.zip
When I run command:
node server.js
I get error:
My environments:
- OS: MacOS Catalina 10.15.5
- Node: v10.16.0
- NPM: 6.9.2
- Canvas: canvas@2.6.1
Please help me resolve this problem.
Is there any document guide to build node-canvas from source so I can build and debug with node-canvas ( some guides are out of date and have many compile errors ).
Thank you!