resvg
A small, fast, and portable SVG rendering library written entirely in Rust
Repository Health
Technical Analysis
resvg is an SVG rendering library that renders static SVG files to raster images with a strong focus on correctness, safety, and portability. It ships as a Rust library, a C library, and a standalone CLI application, and is built on a suite of sibling crates the same maintainers wrote from scratch — usvg for SVG preprocessing/simplification, tiny-skia for 2D rasterization, rustybuzz for text shaping, and ttf-parser for font parsing — so the entire rendering pipeline is pure Rust with no dependency on system libraries like Cairo or Skia.
Because it avoids OS-level graphics and font-rendering APIs, resvg produces pixel-identical output across platforms and compiles cleanly to WASM. It targets the static SVG 1.1/2 feature subset (no scripting, animation, or interactivity) but backs that subset with an extensive regression test suite of roughly 1600 SVG-to-PNG cases, making it one of the most spec-accurate static SVG renderers available outside of a full browser engine.
What You Get
- A
resvgRust crate for parsing and rendering SVG to atiny-skiapixmap, plus ausvgcrate for pure SVG-to-simplified-SVG preprocessing if you want to bring your own renderer - A C API (
crates/c-api) for embedding the renderer in non-Rust applications - A standalone
resvgCLI binary for converting SVG files to PNG from the command line or CI pipelines - Optional feature flags for text rendering, system font loading, memory-mapped fonts, SVGZ decoding, and raster image embedding, so consumers can trim the binary to only what they need
- A companion resvg-test-suite of ~1600 SVG-to-PNG regression tests, published separately and usable by other SVG library authors
Common Use Cases
- Converting user- or CMS-authored SVG assets (icons, illustrations, charts) to PNG/raster thumbnails at build time or on a server
- Embedding deterministic SVG rendering inside a native desktop or mobile app without shipping a full browser engine
- Rendering SVG in WASM contexts (e.g. browser extensions or edge functions) where a system graphics stack isn’t available
- Generating print-ready or pixel-exact raster exports where cross-platform reproducibility matters more than support for SVG animation/scripting
Under The Hood
Architecture — The project is a Cargo workspace split into crates/usvg (parses raw SVG/XML into a simplified, resolved shape tree — flattening CSS, resolving use/href, computing bounding boxes) and crates/resvg (walks that tree and rasterizes it via tiny-skia), with crates/c-api providing FFI bindings on top of the resvg crate for non-Rust consumers. This preprocess/render split is deliberate: usvg’s output can be consumed by an entirely different renderer, and resvg’s renderer only has to deal with an already-normalized tree rather than raw SVG edge cases. Filter effects (blur, lighting, displacement, convolution, turbulence) each live in their own module under src/filter/, mirroring the SVG filter primitive spec one-to-one.
Tech Stack — Everything is pure Rust (95.9% of the codebase): rendering goes through tiny-skia (a Rust port of a Skia subset), text shaping through rustybuzz (a Rust port of HarfBuzz), font parsing through ttf-parser, and XML parsing through roxmltree — all maintained by the same author/org, avoiding any C/C++ system library dependency. CSS selector matching uses simplecss. The workspace targets Rust 1.87.0+ and edition 2024, with small amounts of C/C++ present only for auxiliary tooling, not the render path.
Code Quality — The library backs its static-SVG claims with a large, separately-published SVG-to-PNG regression suite (~1600 cases) rather than only unit tests, which is unusually rigorous for a rendering library. unsafe is deliberately minimized — the README states there’s almost none outside of inherently-unsafe font memory-mapping — and the code includes explicit guards against infinite loops and stack overflows from recursive SVG constructs (a common source of renderer crashes on adversarial input). Feature flags are used consistently to keep optional capabilities (text, raster images, system fonts) opt-in and the default binary small.
API Design — The crate exposes a straightforward parse-then-render flow (usvg::Tree::from_data → resvg::render into a tiny-skia::Pixmap) demonstrated in minimal, draw_bboxes, and custom_href_resolver examples, and the CLI mirrors the same options as flags. Feature-gating is explicit in Cargo.toml, so consumers pay only for what they enable (e.g. skipping text shaves ~400KiB off the binary). Documentation is maintained on docs.rs alongside a maintained SVG-support compatibility table, which is atypical thoroughness for an OSS rendering library.
Used by 2 apps in this directory
Cap
Team Chat · Video Conferencing
Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.
Spacedrive
File Storage · Collaboration
One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.