Render SVG Images into PDF, PNG, PostScript, or Bitmap Arrays

Renders vector-based svg images into high-quality custom-size bitmap arrays using 'librsvg2'. The resulting bitmap can be written to e.g. png, jpeg or webp format. In addition, the package can convert images directly to various formats such as pdf or postscript.


arrays using 'librsvg'. The resulting bitmap can be written to e.g. 'png', 'jpeg' or 'webp' format. In addition, the package can convert images directly to various formats such as pdf or postscript.

About the R package:

# create some svg
tmp <- tempfile()
svglite::svglite(tmp, width = 10, height = 7)
ggplot2::qplot(mpg, wt, data = mtcars, colour = factor(cyl))
dev.off()
 
# render it into a bitmap array
bitmap <- rsvg(tmp, height = 1440)
dim(bitmap) # h*w*c
png::writePNG(bitmap, "bitmap.png", dpi = 144)
jpeg::writeJPEG(bitmap, "bitmap.jpg", quality = 1)
webp::write_webp(bitmap, "bitmap.webp", quality = 100)
 
# render straight to output format
rsvg_pdf(tmp, "out.pdf")
rsvg_png(tmp, "out.png")
rsvg_svg(tmp, "out.svg")
rsvg_ps(tmp, "out.ps")

Binary packages for OS-X or Windows can be installed directly from CRAN:

install.packages("rsvg")

Installation from source on Linux or OSX requires librsvg2. On Debian or Ubuntu install librsvg2-dev:

sudo apt-get install -y librsvg2-dev

On Fedora, CentOS or RHEL we need librsvg2-devel:

sudo yum install librsvg2-devel

On OS-X use rsvg from Homebrew:

brew install librsvg

News

1.0

  • Upgrade to fully static librsvg 2.40.16 build on Windows
  • Fixed a bug that could cause a freeze or segfault with old versions of librsvg

0.6

  • Update Homebrew URL in configure script
  • Change autobrew to --force-bottle dependencies and use current glib2
  • Add '-framework AppKit' to PKG_LIBS for OSX static binary (needed by CMD check)

0.5

  • Fix for Warning on OSX CRAN builder.
  • Minor tweaks to configure script

0.4

  • Fix autobrew script for Snow Leopard

0.3

  • Add output formats rsvg_png() rsvg_pdf() rsvg_ps() rsvg_svg()
  • Fix for rounding issue in proportional image scaling
  • Add support for url in rsvg()

0.2

  • Initial CRAN release with Windows support

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rsvg")

1.1 by Jeroen Ooms, 4 months ago


https://github.com/jeroen/rsvg#readme


Report a bug at https://github.com/jeroen/rsvg/issues


Browse source code at https://github.com/cran/rsvg


Authors: Jeroen Ooms


Documentation:   PDF Manual  


MIT + file LICENSE license


Suggests svglite, png, jpeg, webp, ggplot2

System requirements: librsvg2


Imported by ionicons, multipanelfigure.

Suggested by DiagrammeR, magick.


See at CRAN