#svg #computer-graphics

bin+lib vtracer

A cmd app to convert images into vector graphics

3 unstable releases

0.2.0 Nov 15, 2020
0.1.1 Nov 1, 2020
0.1.0 Oct 31, 2020

#69 in Images

MIT/Apache

20KB
467 lines

visioncortex VTracer

Raster to Vector Graphics Converter built on top of visioncortex

Docs | Demo | Crate

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 Live Trace, VTracer's output is much more compact (less shapes) as we adopt a stacking strategy and avoid producing shapes with holes.

A technical description of the algorithm is on visioncortex.org/vtracer-docs.

Web App

VTracer and its core library is implemented in Rust. It provides us a solid foundation to develop robust and efficient algorithms and easily bring it to interactive applications. The webapp is a perfect showcase of the capability of the Rust + HTML5 platform.

screenshot

screenshot

Command Line

visioncortex VTracer                                                                                                      
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                                 
    -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                                           
        --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                   

Usage

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

Library

The library can be found on crates.io/vtracer.

Install

vtracer = "0.1.0"

Dependencies

~6MB
~79K SLoC