exupero / saveSvgAsPng

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

Can set the color when exporting PNG? #180

Closed ALein closed 5 years ago

ALein commented 5 years ago

I now make an icon library, hoping to set up the color when SVG is downloaded to PNG, and I don't know how to do it.

exupero commented 5 years ago

Use the modifyCss option. Here's an example:

https://github.com/exupero/saveSvgAsPng/blob/320b56aca265dc410f58ff60d1099ed2cfc4e926/index.js#L50-L54

Let me know if you need something different.

ALein commented 5 years ago

I'm using a remote SVG , which has a originally color, and now I want to change this color when I download it, so you can download a PNG map of different colors.modifyCss can only modify my custom outer style。 `

      </svg>`
exupero commented 5 years ago

Thank you for the clarification. If you want to modify a remote SVG, you'll have to download it with an XHR request and modify the XML. This library doesn't have facility for that.

ALein commented 5 years ago

Thank you very much!