How to export svg image to png file in r?

旧城冷巷雨未停 提交于 2021-02-11 12:33:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!