Created
October 12, 2021 04:32
-
-
Save kgn/c318e858557873b20831b2f453c71f9e to your computer and use it in GitHub Desktop.
Convert svg to png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import svg2img from 'svg2img'; | |
module.exports = (req, res) => { | |
const url = req.query.url; | |
const width = req.query.width; | |
const height = req.query.height; | |
const size = Math.min(width, height); | |
svg2img(url, {width: size, height: size, preserveAspectRatio: true}, | |
function(error, buffer) { | |
if (buffer) { | |
res.send(buffer); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment