Skip to content

Releases: thx/resvg-js

v2.1.0

03 Jul 14:08
Compare
Choose a tag to compare

Added

  • Add imagesToResolve() and resolveImage() APIs to load image URL. By @zimond in #102

    • Supports PNG, JPEG and GIF formats.
    • This only works for xlink:href starting with http:// or https://.
    • See example and playground for more details.

    In order to support loading image URL, we forked the rust side of resvg and made some improvements.

    Now please witness the magic moment:

    load image URL Demo

  • Add innerBBox() API. By @yisibl in #105

    Calculate a maximum bounding box of all visible elements in this SVG. (Note: path bounding box are approx values).

  • Add getBBox() API. By @yisibl in #108

    We designed it to correspond to the SVGGraphicsElement.getBBox() method in the browser.

    This is different from the innerBBox() API, by default it does apply transform calculations and gets the BBox with curves exactly. This works well in most use cases, the only drawback is that it does not calculate BBoxes with stroke correctly.

  • Add cropByBBox() API. By @yisibl in #108

    With this API, we can crop the generated bitmap based on the BBox(bounding box).

    cropByBBox Demo
    const fs = require('fs')
    const { Resvg } = require('@resvg/resvg-js')
    const svg = '' // some SVG string or file.
    const resvg = new Resvg(svg)
    const innerBBox = resvg.innerBBox()
    const bbox = resvg.getBBox()
    
    // Crop the bitmap according to bbox,
    // The argument to the `.cropByBBox()` method accepts `bbox` or `innerBBox`.
    if (bbox) resvg.cropByBBox(bbox)
    const pngData = resvg.render()
    const pngBuffer = pngData.asPng()
    
    console.info('SVG BBox: ', `${bbox.width} x ${bbox.height}`)
    fs.writeFileSync('out.png', pngBuffer)
  • feat: upgrade svgtypes to 0.8.1 to support 4 digits and 8 digits hex colors. By @yisibl in #127

All Changed

  • fix: rebuild Wasm to solve the problem of not working in the browser by @yisibl in #106
  • chore(deps): upgrade napi-rs to 2.4.0 by @yisibl in #107
  • feat: add napi-rs and wasm_bindgen bindings to bbox by @yisibl in #105
  • feat: add cropByBBox and getBBox API by @yisibl in #108
  • build: re-enable the vercel app for playground by @yisibl in #109
  • feat: return undefined if bbox is invalid by @zimond in #110
  • Add image resolver API by @zimond in #102
  • style: rust indent changed from 2 to 4 spaces by @yisibl in #114
  • chore(deps): update dependency sharp to v0.30.5 [security] by @renovate in #116
  • chore: export AR in android pipeline by @yisibl in #121
  • fix(deps): update rust crate mimalloc-rust to 0.2 by @renovate in #119
  • fix(deps): update rust crate napi to 2.5.0 by @renovate in #120
  • chore: upgrade dependencies by @yisibl in #126
  • feat: upgrade svgtypes to 0.8.1 to support HEXA color format by @yisibl in #127
  • build: update the wasm file by @yisibl in #128
  • doc: v2.1.0 changelog by @yisibl in #129

Full Changelog: v2.0.0...v2.1.0

v2.0.1

07 May 05:44
Compare
Choose a tag to compare

What's Changed

  • feat: add bbox related API by @zimond in #90
    This version does not yet implement Node.js or Wasm bindings, so it is not available for now.

  • fix: rebuild Wasm to solve the problem of not working in the browser by @yisibl in #106

Full Changelog: v2.0.0...v2.0.1

v2.0.0

30 Apr 10:20
Compare
Choose a tag to compare
2.0.0

v2.0.0-beta.0

02 Apr 07:07
Compare
Choose a tag to compare
v2.0.0-beta.0 Pre-release
Pre-release

What's Changed

The resvg-js API is now largely stable.

render() now no longer returns the Buffer directly, you need to get the buffer via the new render().asPng(), also added render().width and render().height to return the size of the PNG.

  • feat: render result as a new class by @zimond in #94
  • test: add render().width/height test by @yisibl in #96
  • chore(deps): update dependency eslint-plugin-sonarjs to ^0.13.0 by @renovate in #92
  • chore(deps): bump minimist from 1.2.5 to 1.2.6 by @dependabot in #93

Full Changelog: v2.0.0-alpha.6...v2.0.0-beta.0

v2.0.0-alpha.6

20 Mar 07:33
Compare
Choose a tag to compare
v2.0.0-alpha.6 Pre-release
Pre-release

What's Changed

  • chore: add libc fields on linux platform packages by @yisibl in #89

    On Linux, it is not possible to tell exactly what kind of C library a native modules depends on just by os/cpu, so yarn 3.2 and cnpm added libc fields to further distinguish this case. This avoids downloading both gnu and musl packages at the same time.

    Currently only yarn 3.2+ and cnpm are supported, the npm implementation is still under discussion.

Full Changelog: v2.0.0-alpha.5...v2.0.0-alpha.6

v2.0.0-alpha.5

19 Mar 08:00
Compare
Choose a tag to compare
v2.0.0-alpha.5 Pre-release
Pre-release

What's Changed

  • feat: rounding width / height by @yisibl in #85
  • chore(deps): update dependency @types/sharp to ^0.30.0 by @renovate in #86
  • chore(deps): update actions/upload-artifact action to v3 by @renovate in #87
  • chore(deps): update actions/download-artifact action to v3 by @renovate in #81
  • chore(deps): update actions/checkout action to v3 by @renovate in #80

Full Changelog: v2.0.0-alpha.4...v2.0.0-alpha.5

v2.0.0-alpha.4

14 Mar 05:42
Compare
Choose a tag to compare
v2.0.0-alpha.4 Pre-release
Pre-release

What's Changed

Added

  • feat: strip text features and reduce the size of the generated wasm file.
    • before: 1949570 bytes
    • after: 1266413 bytes
  • feat: upgrade to napi-rs 2.2.0.

Full Changelog: v1.4.0...v2.0.0-alpha.4

v2.0.0-alpha.3

01 Mar 11:24
Compare
Choose a tag to compare
v2.0.0-alpha.3 Pre-release
Pre-release

What's Changed

Added

  • feat: add .width and .height to get the original size of the SVG.
  • feat: add toString() to convert SVG shapes or text to path.

Changed

  • refactor: change to Class API, now instead use new Resvg() to create the constructor.
    With the new Class API, we can avoid rendering the SVG again when getting the SVG size. It also makes it easier to extend new APIs.

Before

const { render } = require('@resvg/resvg-js')
const svg = '' // svg buffer or string
const pngData = render(svg, opts)

After

const { Resvg } = require('@resvg/resvg-js')
const svg = '' // svg buffer or string
const resvg = new Resvg(svg, opts)
const pngData = resvg.render()

// New!
console.info('Simplified svg string \n', resvg.toString())
console.info('SVG original size:', `${resvg.width} x ${resvg.height}px`)

New Contributors

Full Changelog: v1.4.0...v2.0.0-alpha.3

v2.0.0-alpha.2

21 Feb 12:21
Compare
Choose a tag to compare
v2.0.0-alpha.2 Pre-release
Pre-release

What's Changed

Added

  • feat: upgrade resvg to 0.22.0

    Support svg referenced by <use>, this is often used in svg sprite.

    <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" 
      xmlns:xlink="http://www.w3.org/1999/xlink">
      <svg id="svg1" xmlns="http://www.w3.org/2000/svg">
        <rect width="50%" height="50%" fill="green" />
      </svg>
      <use id="use1" x="50%" y="50%" xlink:href="#svg1" />
    </svg>
  • feat: upgrade fontdb to 0.9.0, loading system fonts will become faster.

    There are many CJK fonts installed in my local OS, the test result is 2.5 times faster:

    • Before: Loaded 1085 font faces in 860.447ms.
    • After: Loaded 1085 font faces in 339.665ms.

v2.0.0-alpha.1

17 Feb 12:04
Compare
Choose a tag to compare
v2.0.0-alpha.1 Pre-release
Pre-release

What's Changed

  • feat: playground uses unpkg.com's online resources

    <script src="https://unpkg.com/@resvg/[email protected]/index.min.js"></script>
  • feat: preload wasm in the playground

    <link rel="preload" as="fetch" type="application/wasm" href="https://unpkg.com/@resvg/resvg-wasm/index_bg.wasm" />
  • chore: upload wasm file to artifacts
    Switching from local to building in CI (Linux-x64-gnu) for .wasm files can reduce the file size a bit.

    • Local, Mac-x64-darwin: 1969225 bytes
    • CI, Linux-x64-gnu: 1949570 bytes

    After gzip compression, the .wasm file is only about 700kB.

Full Changelog: v2.0.0-alpha.0...v2.0.0-alpha.1