diff --git a/CHANGELOG.md b/CHANGELOG.md
index 40ea243f..e8f79d5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,11 +9,76 @@ This changelog also contains important changes in dependencies.
## [Unreleased]
+### Added
+
+- Add `imagesToResolve()` and `resolveImage()` APIs to load image URL. By @zimond in [#102](https://github.com/yisibl/resvg-js/pull/102)
+
+ - Supports PNG, JPEG and GIF formats.
+ - This only works for `xlink:href` starting with `http://` or `https://`.
+ - See [example](example/image-url.js) 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](https://user-images.githubusercontent.com/2784308/168537647-6787dfc3-49b6-42bb-be5e-35ddba8072d9.png)
+
+- Add `innerBBox()` API. By @yisibl in [#105](https://github.com/yisibl/resvg-js/pull/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](https://github.com/yisibl/resvg-js/pull/108)
+
+ We designed it to correspond to the [`SVGGraphicsElement.getBBox()`](https://developer.mozilla.org/en-US/docs/Web/API/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](https://github.com/yisibl/resvg-js/pull/108)
+
+ With this API, we can crop the generated bitmap based on the BBox(bounding box).
+
+
+
+ ```js
+ 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](https://www.w3.org/TR/css-color-4/#hex-notation) hex colors. By @yisibl in [#127](https://github.com/yisibl/resvg-js/pull/127)
+
+### Changed
+
+- feat: return undefined if bbox is invalid. By @zimond in [#110](https://github.com/yisibl/resvg-js/pull/110)
+- chore: use jimp-compact instead of jimp.
+- fix(deps): update rust crate napi to 2.5.0.
+- fix(deps): update rust crate mimalloc-rust to 0.2.
+- chore: export AR in android pipeline.
+- style: rust indent changed from 2 to 4 spaces.
+
## [2.0.1] - 2022-05-07
+### Added
+
+- feat: add bbox related API. @zimond in [#90](https://github.com/yisibl/resvg-js/pull/90)
+
+ This version does not yet implement Node.js or Wasm bindings, so it is not available for now.
+
### Fixed
-- fix: rebuild Wasm to solve the problem of not working in the browser
+- fix: rebuild Wasm to solve the problem of not working in the browser.
## [2.0.0] - 2022-04-30
diff --git a/README.md b/README.md
index bb3dab3d..06328718 100755
--- a/README.md
+++ b/README.md
@@ -166,23 +166,27 @@ Running "resize width" suite...
- Install latest `Rust`
- Install `Node.js@10+` which fully supported `Node-API`
- Install `wasm-pack`
+
```bash
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
```
+
Normally `wasm-pack` will install `wasm-bindgen` automatically, but if the installation [fails due to network reasons](https://github.com/rustwasm/wasm-pack-template/issues/44#issuecomment-521657516), please try to install it manually.
- ```bash
- cargo install wasm-bindgen-cli
+
+ ```bash
+ cargo install wasm-bindgen-cli
```
On computers with Apple M chips, the following error message may appear:
+
> Error: failed to download from https://github.com/WebAssembly/binaryen/releases/download/version_90/binaryen-version_90-x86_64-apple-darwin.tar.gz
Please install binaryen manually:
+
```bash
brew install binaryen
```
-
### Build Node.js bindings
```bash
diff --git a/example/image-url.js b/example/image-url.js
index e3a78179..23bb8bbc 100644
--- a/example/image-url.js
+++ b/example/image-url.js
@@ -6,7 +6,12 @@ const fetch = require('node-fetch')
const { Resvg } = require('../index')
async function main() {
- const svg = await promises.readFile(join(__dirname, './url.svg'))
+ const svg = `
+
+
+ `
const opts = {
font: {
loadSystemFonts: false, // It will be faster to disable loading system fonts.
diff --git a/example/url.svg b/example/url.svg
deleted file mode 100644
index 9a900dc2..00000000
--- a/example/url.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
diff --git a/package.json b/package.json
index c0a04bca..999ffd9f 100644
--- a/package.json
+++ b/package.json
@@ -94,6 +94,7 @@
"jimp-compact": "^0.16.1-2",
"lint-staged": "^12.5.0",
"npm-run-all": "^4.1.5",
+ "node-fetch": "2.x",
"prettier": "^2.7.1",
"sharp": "^0.30.7",
"typescript": "^4.7.4"
diff --git a/yarn.lock b/yarn.lock
index e3a8bcf3..1807a5e3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2633,6 +2633,13 @@ node-addon-api@^5.0.0:
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.0.0.tgz#7d7e6f9ef89043befdb20c1989c905ebde18c501"
integrity sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==
+node-fetch@2.x:
+ version "2.6.7"
+ resolved "https://registry.npmmirror.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
+ integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
+ dependencies:
+ whatwg-url "^5.0.0"
+
noms@0.0.0:
version "0.0.0"
resolved "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859"
@@ -3642,6 +3649,11 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"
+tr46@~0.0.3:
+ version "0.0.3"
+ resolved "https://registry.npmmirror.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
+ integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
+
trim-off-newlines@^1.0.1:
version "1.0.3"
resolved "https://registry.npmmirror.com/trim-off-newlines/download/trim-off-newlines-1.0.3.tgz#8df24847fcb821b0ab27d58ab6efec9f2fe961a1"
@@ -3816,11 +3828,24 @@ wcwidth@^1.0.1:
dependencies:
defaults "^1.0.3"
+webidl-conversions@^3.0.0:
+ version "3.0.1"
+ resolved "https://registry.npmmirror.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
+ integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
+
well-known-symbols@^2.0.0:
version "2.0.0"
resolved "https://registry.nlark.com/well-known-symbols/download/well-known-symbols-2.0.0.tgz#e9c7c07dbd132b7b84212c8174391ec1f9871ba5"
integrity sha1-6cfAfb0TK3uEISyBdDkewfmHG6U=
+whatwg-url@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.npmmirror.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
+ integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
+ dependencies:
+ tr46 "~0.0.3"
+ webidl-conversions "^3.0.0"
+
which-boxed-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.nlark.com/which-boxed-primitive/download/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"