Package Exports
- @resvg/resvg-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@resvg/resvg-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
resvg-js
resvg-js is a high-performance SVG renderer, powered by Rust based resvg and napi-rs.
- Fast, safe and zero dependencies!
- No need for node-gyp and postinstall, the
.nodefile has been compiled for you. - Cross-platform support, including Apple M1.
- Support system fonts and custom fonts in SVG text.
Installation
npm i @resvg/resvg-js
cnpm i @resvg/resvg-js
pnpm i @resvg/resvg-jsExample
This example will load Source Han Serif, and then render the SVG to PNG.
node example/index.js
Loaded 1 font faces in 0ms.
Font './example/SourceHanSerifCN-Light-subset.ttf':0 found in 0.006ms.
✨ Done in 55.65491008758545 ms| SVG | PNG |
|---|---|
![]() |
|
![]() |
Benchmark
Running "resize width" suite...
resvg-js(Rust):
12 ops/s, ±22.66% | fastest 🚀
sharp:
9 ops/s, ±64.52% | 25% slower
skr-canvas(Rust):
7 ops/s, ±3.72% | 41.67% slower
svg2img(canvg and node-canvas):
6 ops/s, ±16.94% | slowest, 50% slowerSupport matrix
Test in local
- Install latest
Rust - Install
Node.js@10+which fully supportedNode-API
npm i
npm build
npm testRoadmap & Contributing
I will consider implementing the following features, if you happen to be interested, please feel free to discuss with me or submit a PR.
- Support async API
- Upgrade to napi-rs v2
- Support for getting SVG Bounding box
- Output usvg-simplified SVG string
- Support for generating more lossless bitmap formats, e.g. avif, webp, JPEG XL
- Support WebAssembly(.wasm)
Release package
We use GitHub actions to automatically publish npm packages.
# 1.0.0 => 1.0.1
npm version patch
# or 1.0.0 => 1.1.0
npm version minor
git push --follow-tags
