10 releases (5 breaking)

0.6.3 Nov 21, 2023
0.6.1 Sep 23, 2023
0.5.0 Oct 9, 2022
0.4.0 Jul 23, 2021
0.2.0 Nov 15, 2020

#400 in Images

Download history 24/week @ 2024-07-27 16/week @ 2024-08-03 18/week @ 2024-08-10 14/week @ 2024-08-17 21/week @ 2024-08-24 22/week @ 2024-08-31 29/week @ 2024-09-07 33/week @ 2024-09-14 64/week @ 2024-09-21 49/week @ 2024-09-28 29/week @ 2024-10-05 35/week @ 2024-10-12 34/week @ 2024-10-19 22/week @ 2024-10-26 18/week @ 2024-11-02 182/week @ 2024-11-09

259 downloads per month
Used in u_u

MIT/Apache

34KB
757 lines

VTracer

Raster to Vector Graphics Converter built on top of visioncortex

Article | Demo | Download

Built with 🦀 by The Vision Cortex Research Group

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.

Cmd App

visioncortex VTracer 0.6.0
A cmd app to convert images into vector graphics.

USAGE:
    vtracer [OPTIONS] --input <input> --output <output>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --colormode <color_mode>                 True color image `color` (default) or Binary image `bw`
    -p, --color_precision <color_precision>      Number of significant bits to use in an RGB channel
    -c, --corner_threshold <corner_threshold>    Minimum momentary angle (degree) to be considered a corner
    -f, --filter_speckle <filter_speckle>        Discard patches smaller than X px in size
    -g, --gradient_step <gradient_step>          Color difference between gradient layers
        --hierarchical <hierarchical>
            Hierarchical clustering `stacked` (default) or non-stacked `cutout`. Only applies to color mode.

    -i, --input <input>                          Path to input raster image
    -m, --mode <mode>                            Curver fitting mode `pixel`, `polygon`, `spline`
    -o, --output <output>                        Path to output vector graphics
        --path_precision <path_precision>        Number of decimal places to use in path string
        --preset <preset>                        Use one of the preset configs `bw`, `poster`, `photo`
    -l, --segment_length <segment_length>
            Perform iterative subdivide smooth until all segments are shorter than this length

    -s, --splice_threshold <splice_threshold>    Minimum angle displacement (degree) to splice a spline

Install

You can download pre-built binaries from Releases.

You can also install the program from source from crates.io/vtracer:

cargo install vtracer

Usage

./vtracer --input input.jpg --output output.svg

Rust Library

You can install vtracer as a Rust library.

cargo add vtracer

Python Library

Since 0.6, vtracer is also packaged as Python native extensions, thanks to the awesome pyo3 project.

pip install vtracer

Dependencies

~8–13MB
~126K SLoC