Raster to Vector Graphics Converter
visioncortex VTracer is an open source software to convert raster images (like jpg & png) into vector graphics (svg). It can vectorize graphics and photographs and trace the curves to output compact vector files.
Comparing to Potrace, VTracer has an image processing pipeline which can handle colored images. VTracer skips Potrace's expensive optimal-polygon search in favor of a fast, linear pipeline that stays faithful to high-resolution images.
Comparing to Adobe Illustrator's Image Trace, VTracer's output is much more compact as we adopt a stacking strategy and avoid producing shapes with holes.
VTracer is originally designed for processing high resolution scans of historic blueprints up to gigapixels. At the same time, VTracer can also handle low resolution pixel art, simulating image-rendering: pixelated for retro game artworks.
Technical descriptions of the tracing algorithm and clustering algorithm.
VTracer App powered by the 1.0 tracing engine:
You can download pre-built binaries from Releases.
You can also install the program from source:
cargo install vtracer-cli
# simplest form
./vtracer input.jpg output.svg
# black & white line art
./vtracer input.jpg output.svg --preset bw
# scanned/photographed line art with uneven lighting
./vtracer scan.jpg output.svg --clustering bw --adaptive
# seam-free mosaic (gapless tessellation)
./vtracer input.jpg output.svg --hierarchical cutout
# watershed region forming, cut to taste
./vtracer photo.jpg output.svg --clustering watershed --watershed-detail 192
# constrain to a fixed palette
./vtracer input.jpg output.svg --palette '#1b1b1b,#e0c088,#5a7d3c,#8fb0d0'
Full options:
…
The spline fine-tuning flags --corner-threshold <0..=180>,
--segment-length <3.5..=10>, and --splice-threshold <0..=180> are still
accepted but hidden from --help: their defaults (60 / 4 / 45) serve
virtually every conversion, and --simplify is the knob that actually moves
output size and smoothness.
vtracer in.png out.svg.--hierarchical cutout is now a true seam-free mosaic (a gapless
tessellation with shared boundaries), replacing the old re-clustered cutout.--palette / --palette-file: snap colors to a fixed palette
(nearest in OKLab); --max-colors auto-quantizes the palette.--threshold) or
Bradley–Roth adaptive thresholding (--adaptive, with --adaptive-window
/ --adaptive-t) for scans with uneven lighting.--simplify <tolerance>: paper.js-style curve simplification: re-fits
smooth runs with the fewest cubics that stay within the tolerance (px),
typically halving file size; seam-free in cutout mode because shared
boundaries are simplified once for both faces.--clustering watershed: an alternative region-forming algorithm: a
hierarchical watershed on the pixel graph (Cousty et al., TPAMI 2009; Najman,
Cousty & Perret, ISMM 2013), cut at --watershed-detail. Content-adaptive
regions that follow object shape: pairs beautifully with cutout.VTracer 1.0 is a vectorization framework with pluggable stages: segmentation, curve fitting, color fitting, and output optimization — usable from the command line or as a library in Rust, Python, and JavaScript:
Package Registry Source Usevtracer-cli
crates.io
crates/vtracer-cli
Command-line tool (vtracer binary)
vtracer
crates.io
crates/vtracer
Rust library / the framework core
vtracer
PyPI
crates/vtracer-py
Python native extension (pyo3 + maturin)
@visioncortex/vtracer
npm
nodejs
Node.js WebAssembly build, no native dependency
cargo add [email protected]
…
Split the pipeline when you want the stages separately — segment caches, finish re-runs:
let pipeline = cfg.build()?;
let seg = pipeline.segment(&img)?; // the expensive part
let doc = pipeline.finish(&seg)?; // VectorDoc, ready to serialize
See docs.rs/vtracer for the full API.
pip install vtracer==1.0.0a4
…
See crates/vtracer-py for the full API.
@visioncortex/vtracer is available for Node as a WebAssembly build (from the nodejs package) — image decoding and vectorization both run in wasm, so there is no native dependency. Decodes PNG, JPEG, GIF, BMP, and WebP; for other formats, decode yourself and pass raw RGBA to convertPixels.
npm install @visioncortex/[email protected]
const vtracer = require('@visioncortex/vtracer');
await vtracer.convertFile('in.png', 'out.svg', { mode: 'polygon' });
const svg = vtracer.convertBuffer(buffer, { preset: 'poster' });
const svg2 = vtracer.convertPixels(rgba, width, height, { clustering: 'bw' });
// binary with adaptive thresholding
const bw = vtracer.convertBuffer(buffer, { clustering: 'bw', adaptive: true });
VTracer has since been cited by a few academic papers in computer graphics / vision research. Please kindly let us know if you have cited our work:
No open issues yet, or sync has not completed.