Automattic / Automattic/node-canvas

Can't load svg with base64 image inside

Open
#1,607 8 comments 6 reactions 0 assignees View on GitHub
Bug Good first issue Help wanted SVG
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## Issue or Feature
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`

## Steps to Reproduce

1. Run following code to load svg file:

```js
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();
```
Here is svg file:

[input.svg.zip](https://github.com/Automattic/node-canvas/files/4774170/input.svg.zip)

2. In the terminal run command:
node server.js

3. Get Error:
GdkPixbuf-CRITICAL **: 13:03:49.842: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

![error_load_svg_with_base64](https://user-images.githubusercontent.com/8949278/84561630-4b589a00-ad78-11ea-97c9-1734a1c2be83.jpg)

## Your Environment
OS: MacOS Catalina 10.15.5
Node: v10.16.0
NPM: 6.9.2
Canvas: canvas@2.6.1

## Expected:
SVG file is loaded & rendered normally.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.