Closed eaaliprantis closed 7 years ago
A Buffer containing the contents of the svg file you plan to convert.
Would you be able to provide an example? I mean would i just put as a sourceBuffer a string of what i would want to name the file? I'm still somewhat confused.
Are you confused as to how you get a buffer? That is a general Node.js question that might be best for StackOverflow. But there are many ways. E.g.
const buffer = require("fs").readFileSync("file.svg");
I understand what a buffer does but if the image comes directly from a website (i.e. http://discjamdojo.challonge.com/naduet3.svg). What exactly, in this case, would be the "source" buffer"?
The source buffer is, as I said, a buffer containing the contents of the svg file you plan to convert. So, the bytes at that URL.
If you are having trouble figuring out how to download things from URLs and turn them into buffers, again, that is a good stackoverflow question.
A lot of people would have probably been more appreciative if you actually provide examples from a url and converting it to the sourceBuffer/buffer, but I understand if you chose not to.
Yes, I don't think it's in scope for this repository to provide a tutorial on how to download things in Node.js.
Hello,
While looking at the documentation, what exactly is needed for "sourceBuffer" in this example?
svg2png(sourceBuffer, { url: "https://example.com/awesomeness.svg" }) .then(buffer => ...) .catch(e => console.error(e));