问题
I have some svg images that I want to export as png files, using r. Is there a function that can do that? Until now I only found function that export r plots to png.
But how could I export e.g. this example as a png?
<svg height="100" width="100">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>
回答1:
rsvg
https://github.com/jeroenooms/rsvg is designed to specifically to do this, and I'll say it does it very quickly.
回答2:
The package convertGraph may be the solution here. It claims to convert SVG to other image formats (PNG, JPG, etc.). It requires phantomjs for the conversion.
回答3:
The convertGraph R package can convert graphical file formats within R and does not even require RStudio. So any SVG file can be exported to PNG, PDF, JPEG, GIF, ... and you also have control over the resolution of the exported image.
In addition, it can convert other file formats to one another (e.g. PNG to PDF, PNG to JPEG, GIF to PNG, etc...). The package is hosted on CRAN as well as GitHub.
来源:https://stackoverflow.com/questions/34121809/how-to-export-svg-image-to-png-file-in-r