Skip to content
SVG renderer for R based on librsvg2
Branch: master
Clone or download
Latest commit 6448a5c Feb 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
inst
man
src
tests Setup spell checker Apr 18, 2018
tools
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE Add license file Jan 6, 2016
NAMESPACE
NEWS
README.md
appveyor.yml
cleanup
configure
configure.win
rsvg.Rproj

README.md

rsvg

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

Build Status AppVeyor Build Status CRAN_Status_Badge CRAN RStudio mirror downloads Github Stars

Renders vector-based 'svg' images into high-quality custom-size bitmap 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.

Documentation

About the R package:

Hello World

# 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")

Installation

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
You can’t perform that action at this time.