Automattic/node-canvas

SVG not scaling with context

開放

#1,474 建立於 2019年9月24日

 (4 則留言) (0 個反應) (0 位負責人)JavaScript (1,195 個分叉)batch import
Help wanted

倉庫指標

星標
 (10,689 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Issue or Feature

I'm not sure if i opened this issue already, or just commented in the old svg resize issue that i cannot find anymore.

In browser canvas SVGs are resized and re rendered with the context scale other than the width and height assigned.

In node canvas rendering a svg on a scaled context gives blurred results.

Steps to Reproduce

const fs = require('fs');
const { createCanvas, loadImage } = require('canvas')
const canvas = createCanvas(500, 500)
const ctx = canvas.getContext('2d');

ctx.scale(20, 20);

loadImage('http://thenewcode.com/assets/images/thumbnails/homer-simpson.svg').then((image) => {
  ctx.drawImage(image, 100, 100, 400, 400, 0, 0, 500, 500);
  var stream = canvas.createPNGStream();
  stream.pipe(fs.createWriteStream('output.png'));
})

image

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas):
  • Environment (e.g. node 10.0.0 on Mac OS X 10.8):

貢獻者指南