* Python bindings sep 2023 (#52) * Added maturin-based Python binding, to be deployed to https://pypi.org/project/vtracer/ * Removed poetry mentions from pyproject.toml, added README_PY.md for use on PYPI * -> v0.6.1 -> moved Python bindings to bottom of converter.rs * - README_PY.md needed to be inside the cmdapp directory to display on PyPi.irg -> v0.6.3 * Move code around * Edit Readme * Edit RELEASES.md * Feature guard * Build wheels with the cmdapp/Cargo.toml rather than top-level Cargo.toml * use cmdapp/Cargo.toml for all Maturin CI actions, which causes Github to build all platforms python wheels and submit a new release to PyPI * Bump to 0.6.4 for new PyPI release with all platforms' wheels included * PyPI didn't accept a 'linux_aarch64' wheel for a release. For the moment, remove the platform until I can convince the action to build 'manylinux_aarch64' or the like * Version bump while I work out CI & PyPI release wrinkles * Maturin authors say `compatibility = "linux"` in pyproject.toml is causing PyPI failure. Replacing with "manylinux2014" * bump to v0.7.0 in preparation for release from original vtracer repo --------- Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
VTracer: Python Binding
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.
Install (Python)
pip install vtracer
Usage (Python)
import vtracer
input_path = "/path/to/some_file.jpg"
output_path = "/path/to/some_file.vtracer.jpg"
# Minimal example: use all default values, generate a multicolor SVG
vtracer.convert_image_to_svg_py(inp, out)
# Single-color example. Good for line art, and much faster than full color:
vtracer.convert_image_to_svg_py(inp, out, colormode='binary')
# All the bells & whistles
vtracer.convert_image_to_svg_py(inp,
out,
colormode = 'color', # ["color"] or "binary"
hierarchical = 'stacked', # ["stacked"] or "cutout"
mode = 'spline', # ["spline"] "polygon", or "none"
filter_speckle = 4, # default: 4
color_precision = 6, # default: 6
layer_difference = 16, # default: 16
corner_threshold = 60, # default: 60
length_threshold = 4.0, # in [3.5, 10] default: 4.0
max_iterations = 10, # default: 10
splice_threshold = 45, # default: 45
path_precision = 3 # default: 8
)
Rust Library
The (Rust) library can be found on crates.io/vtracer and crates.io/vtracer-webapp.