Git Product home page Git Product logo

resvg-js's Introduction

resvg-js

GitHub CI Status npm version

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 .node file 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-js

Example

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
Anime girl SVG Anime girl 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% slower

Support matrix

node12 node14 node16 npm
Windows x64 npm version
Windows x32 npm version
Windows arm64 npm version
macOS x64 npm version
macOS arm64(M1) npm version
Linux x64 gnu npm version
Linux x64 musl npm version
Linux arm gnu npm version
Linux arm64 gnu npm version
Linux arm64 musl npm version
Android arm64 npm version
Android armv7 npm version

Test in local

  • Install latest Rust
  • Install Node.js@10+ which fully supported Node-API
npm i
npm build
npm test

Roadmap & 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

License

MPLv2.0

resvg-js's People

Contributors

axelhzf avatar brooooooklyn avatar dependabot[bot] avatar renovate-bot avatar renovate[bot] avatar yisibl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.