Skip to content

v2.1.0

Compare
Choose a tag to compare
@github-actions github-actions released this 03 Jul 14:08
· 175 commits to main since this release

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