Introduction
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 which only accept binarized inputs (Black & White pixmap), VTracer has an image processing pipeline which can handle colored high resolution scans.
Comparing to Adobe Illustrator's Image Trace, VTracer's output is much more compact (less shapes) 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.
A technical description of the algorithm is on visioncortex.org/vtracer-docs.
Install (Python)
pip install vtracer
Usage (Python)
import vtracer
input_path = "/path/to/some_file.jpg"
output_path = "/path/to/some_file.vtracer.jpg"
vtracer.convert_image_to_svg_py(inp, out)
vtracer.convert_image_to_svg_py(inp, out, colormode='binary')
input_img_bytes: bytes = get_bytes()
svg_str: str = vtracer.convert_raw_image_to_svg(input_img_bytes, img_format = 'jpg')
from PIL import Image
img = Image.open(input_path).convert('RGBA')
pixels: list[tuple[int, int, int, int]] = list(img.getdata())
svg_str: str = vtracer.convert_pixels_to_svg(pixels)
vtracer.convert_image_to_svg_py(inp,
out,
colormode = 'color',
hierarchical = 'stacked',
mode = 'spline',
filter_speckle = 4,
color_precision = 6,
layer_difference = 16,
corner_threshold = 60,
length_threshold = 4.0,
max_iterations = 10,
splice_threshold = 45,
path_precision = 3
)
Rust Library
The (Rust) library can be found on crates.io/vtracer and crates.io/vtracer-webapp.