exupero / saveSvgAsPng

Save SVGs as PNGs from the browser.
MIT License
1.09k stars 362 forks source link

Use obtained png within the same page #157

Closed ggonmar closed 6 years ago

ggonmar commented 6 years ago

Hello there,

I am trying to implement a feature with this library and I am struggling with how to do so, I hope someone can help me out: I have an icon file on svg format, which I want to modify color, include a text on it, and then set as favicon of the page, all this programatically via Javascript.

Since the favicon does not accept SVG files as valid input, I am trying to use this library for this objective, but the only thing that I have managed is to literally download the png that I want to use. How can I do so to refer to this outputted png to be used on the page?

Thank you for your time and help!

exupero commented 6 years ago

To get an SVG as a PNG without downloading, use the function svgAsPngUri. It takes an SVG node, an options object, and a callback to which it will pass a data URI string of the SVG as a PNG image.

ggonmar commented 6 years ago

That made it! Thank you!