resvg
backend implementation using the [Qt] library.
Since there are no Qt binding for Rust yet, we are using our own. This complicates the build process a bit.
On Windows and macOS, the build process consists of setting the QT_DIR
environment variable and
running cargo build
. On Linux we are using pkg-config
instead.
Install:
stable-x86_64-pc-windows-msvc
[Rust] target.Build using x64 Native Tools Command Prompt for VS 2017
shell:
```batch set PATH=%userprofile%.cargo\bin;%PATH% set QTDIR=C:\Qt\5.12.0\msvc201764 rustup.exe default stable-x86_64-pc-windows-msvc
cargo.exe build --release ```
Instead of msvc2017_64
you can use any other Qt MSVC build. Even 32-bit one.
We are using Qt 5.12.0 just for example.
Install:
stable-x86_64-pc-windows-gnu
[Rust] target.Build using cmd.exe
:
```batch set PATH=C:\Qt\5.12.0\mingw7364\bin;C:\Qt\Tools\mingw73064\bin;%userprofile%.cargo\bin;%PATH% set QTDIR=C:\Qt\5.12.0\mingw7364 rustup.exe default stable-x86_64-pc-windows-gnu
cargo.exe build --release ```
Instead of mingw73_64
you can use any other Qt mingw build.
We are using Qt 5.12.0 just for example.
Install Qt and harfbuzz
using your distributive's package manager.
On Ubuntu you can install them via:
sudo apt install qtbase5-dev libharfbuzz-dev
Build resvg
:
sh
cargo build --release
If you don't want to use the system Qt, you can alter it with the PKG_CONFIG_PATH
variable.
sh
PKG_CONFIG_PATH='/path_to_qt/lib/pkgconfig' cargo build --release
Using an official Qt installer:
sh
QT_DIR=/Users/$USER/Qt/5.12.0/clang_64 cargo build --release
or homebrew:
```sh brew install qt
QT_DIR=/usr/local/opt/qt cargo build --release ```
We are using Qt 5.12.0 just for example.
resvg-qt
depends only on QtCore and QtGui libraries and imageformats/qjpeg plugin.
Technically, any Qt 5 version should work, but we only support Qt >= 5.6.
sh
cargo run --release -- in.svg out.png
The resulting binary can be found at: target/release/resvg-qt
Note: we assume that you have already set up the QT_DIR
variable or pkg-config,
as was described above.
A simple SVG to PNG converter:
sh
cargo run --example minimal -- in.svg out.png
Render image using a manually constructed SVG render tree:
sh
cargo run --example custom_rtree
Draw bounding boxes around all shapes on input SVG:
sh
cargo run --example draw_bboxes -- bboxes.svg bboxes.png -z 4