Skip to content

Instantly share code, notes, and snippets.

@Iainmon
Created May 23, 2021 01:51
Show Gist options
  • Save Iainmon/70653a00c40e699df10564b5d72f1fcb to your computer and use it in GitHub Desktop.
Save Iainmon/70653a00c40e699df10564b5d72f1fcb to your computer and use it in GitHub Desktop.
const sharp = require('sharp');
const fs = require('fs').promises;
const SVG = require('@svgdotjs/svg.js');
const main = async () => {
const buffer = await fs.readFile(__dirname + '/dist/img/sprites/svg/bella-day.svg');
// sharp(buffer).resize().toFormat('png').toFile('bella.png');
const bufferString = buffer.toString();
const draw = SVG.SVG();
const out = draw.svg(bufferString);
console.log(out);
};
main();
// http://snapsvg.io/docs/
// https://www.npmjs.com/package/svg.js
// https://stackoverflow.com/questions/36133657/is-there-a-way-to-make-svg-js-work-with-node-js/50743220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment