Automattic / Automattic/node-canvas
Support transform of element with `transform-box: fill-box; transform-origin: 50% 50%`
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
Each of these SVG's defines a centred square:
```svg
```
Suppose we `loadImage` the SVG then `drawImage`, and finally save as PNG.
- The first two work as expected.
- However _the third produces an empty PNG_.
Code loading an SVG and saving as PNG.
```ts
import fs from 'fs';
import { promises as stream } from 'stream';
import nodeCanvas from 'canvas';
const svgPath = '/path/to/file.svg';
const image = await nodeCanvas.loadImage(svgPath);
const canvas = new nodeCanvas.Canvas(image.width, image.height);
canvas.getContext('2d').drawImage(image, 0, 0);
const outputSvgFilePath = '/path/to/file.png';
await stream.pipeline(
canvas.createPNGStream({}),
fs.createWriteStream(outputSvgFilePath),
);
```
This problem arises naturally in the context of [BoxySVG](https://boxy-svg.com/app).
I just created a centred square, then rotated it by 90° using the Geometry panel.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.