13 releases (breaking)

0.11.0 Jul 4, 2020
0.9.0 Jan 18, 2020
0.8.0 Aug 17, 2019
0.7.0 Jun 19, 2019
0.1.0 Dec 18, 2017

#10 in Images

Download history 871/week @ 2020-04-22 1512/week @ 2020-04-29 1376/week @ 2020-05-06 1794/week @ 2020-05-13 956/week @ 2020-05-20 2110/week @ 2020-05-27 1515/week @ 2020-06-03 1055/week @ 2020-06-10 875/week @ 2020-06-17 1183/week @ 2020-06-24 1136/week @ 2020-07-01 990/week @ 2020-07-08 719/week @ 2020-07-15 380/week @ 2020-07-22 412/week @ 2020-07-29 389/week @ 2020-08-05

5,286 downloads per month
Used in 17 crates (10 directly)

MPL-2.0 license

7.5MB
15K SLoC

resvg

Build Status Crates.io Documentation

resvg is an SVG rendering library.

Purpose

resvg can be used as a Rust library, a C library and as a CLI application to render SVG files based on a static SVG Full 1.1 subset.

The core idea is to make a fast, small, portable SVG library designed for edge-cases. Right now, a resvg CLI application is less than 4MiB and doesn't require any external dependencies.

At the moment, there are no production-ready 2D rendering libraries for Rust. Because of that, resvg relies on Skia.

Another major difference from other SVG rendering libraries is that resvg does a lot of preprocessing before rendering. It converts an input SVG into a simplified one called Micro SVG and only then it begins rendering. So it's very easy to implement a new rendering backend. But we officially support only the Skia one. And you can also access Micro SVG as XML directly via the usvg tool.

SVG support

resvg is aiming to support only the static SVG subset; e.g. no a, script, view or cursor elements, no events and no animations.

SVG Tiny 1.2 and SVG 2.0 are not supported and not planned.

Results of the resvg test suite:

You can find a complete table of supported features here. It also includes alternative libraries.

Performance

Comparing performance between different SVG rendering libraries is like comparing apples and oranges. Everyone has a very different set of supported features, implementation languages, build flags, etc. But since resvg is written in Rust and uses Skia for rendering - it's pretty fast.

Building

Despite being a Rust library, resvg depends on Skia and harfbuzz, therefore you will need a modern C++ compiler. But in most cases the compilation process should be as easy as:

cargo build --release

which will produce binaries that doesn't require any external dependencies.

And while we can leave harfbuzz compilation to Cargo, Skia is more troublesome. Mainly because it requires clang and no other compilers.

By default, resvg uses it's own Skia bindings called tiny-skia. Which supports only clang too. See the Build with embedded Skia section for details. And yes, you can use your own Skia build too.

Also, we do not support 32-bit builds and MINGW target.

Safety

Since resvg depends on C++ libraries, it's inherently unsafe in Rust terms. Despite of that, most of the dependencies are actually fully safe. The main exceptions are Skia and harfbuzz bindings, and files memory mapping.

License

resvg project is licensed under the MPLv2.0.

Dependencies

~5MB
~101K SLoC