domenic / svg2png

Converts SVGs to PNGs, using PhantomJS
Other
585 stars 134 forks source link

Examples #85

Closed eaaliprantis closed 7 years ago

eaaliprantis commented 7 years ago

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));

domenic commented 7 years ago

A Buffer containing the contents of the svg file you plan to convert.

eaaliprantis commented 7 years ago

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.

domenic commented 7 years ago

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");
eaaliprantis commented 7 years ago

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"?

domenic commented 7 years ago

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.

eaaliprantis commented 7 years ago

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.

domenic commented 7 years ago

Yes, I don't think it's in scope for this repository to provide a tutorial on how to download things in Node.js.