4 Commits

Author SHA1 Message Date
Chris Tsang 022018beb2 0.6.1 2023-09-23 11:12:34 +01:00
Chris Tsang cc39c8c5ca README 2023-09-23 11:06:18 +01:00
Evan Jones fa1ab68ef3 Python Bindings. Again. No, really! (#55)
* - Cargo.toml:  add `crate-type = ["cdylib"] to [lib]; lacking this is what was causing the executable to be put in wheels
- pyproject.toml: add "python-binding" to features for conditional compilation
- main.rs:  `cargo build` was failing for the vtracer executable; I think the previous import scheme had an implicit dependency on the library being built and called 'vtracer'. The other way to do this would have been to add an explicit dependency to the [[bin]], but making explicit imports here solves things directly

* re-enable linux builds; features are defined in the pyproject.toml now rather than in the workflow arguments

* And publish Linux, too!
2023-09-23 02:10:04 +08:00
Chris Tsang b04738fd18 well 2023-09-16 19:38:07 +01:00
8 changed files with 187 additions and 56 deletions
+25 -25
View File
@@ -16,28 +16,28 @@ permissions:
contents: read
jobs:
# linux:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Build wheels
# uses: PyO3/maturin-action@v1
# with:
# target: ${{ matrix.target }}
# args: -m cmdapp/Cargo.toml --release --lib --features=python-binding --out dist --find-interpreter
# sccache: 'true'
# manylinux: auto
# - name: Upload wheels
# uses: actions/upload-artifact@v3
# with:
# name: wheels
# path: dist
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: -m cmdapp/Cargo.toml --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
windows:
runs-on: windows-latest
@@ -54,7 +54,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: -m cmdapp/Cargo.toml --release --lib --features=python-binding --out dist --find-interpreter
args: -m cmdapp/Cargo.toml --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
@@ -76,7 +76,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: -m cmdapp/Cargo.toml --release --lib --features=python-binding --out dist --find-interpreter
args: -m cmdapp/Cargo.toml --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
@@ -108,7 +108,7 @@ jobs:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
if: "startsWith(github.ref, 'refs/tags/')"
needs: [windows, macos, sdist]
needs: [windows, macos, sdist, linux]
steps:
- uses: actions/download-artifact@v3
with:
+10 -4
View File
@@ -5,17 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## 0.6.0 - 2023-09-16
## 0.6.1 - 2023-09-23
* Fixed "The two lines are parallel!"
### Python Binding
Thanks to the contribution of [@etjones](https://github.com/etjones), we now have an official Python binding!
Thanks to the contribution of [@etjones](https://github.com/etjones), we now have an official Python binding! https://github.com/visioncortex/vtracer/pull/55
https://pypi.org/project/vtracer/0.6.7/
https://pypi.org/project/vtracer/0.6.10/
## 0.5.0 - 2022-10-09
* Handle transparent png images (cli) (#23)
* Handle transparent png images (cli) https://github.com/visioncortex/vtracer/pull/23
## 0.4.0 - 2021-07-23
@@ -29,6 +31,10 @@ https://pypi.org/project/vtracer/0.6.7/
* Use relative & closed paths
## 0.1.1 - 2020-11-01
* SVG namespace
## 0.1.0 - 2020-10-31
* Initial release
+42 -19
View File
@@ -8,14 +8,14 @@
</p>
<h3>
<a href="//www.visioncortex.org/vtracer-docs">Article</a>
<a href="https://www.visioncortex.org/vtracer-docs">Article</a>
<span> | </span>
<a href="//www.visioncortex.org/vtracer/">Demo</a>
<a href="https://www.visioncortex.org/vtracer/">Demo</a>
<span> | </span>
<a href="//github.com/visioncortex/vtracer/releases/latest">Download</a>
<a href="https://github.com/visioncortex/vtracer/releases/latest">Download</a>
</h3>
<sub>Built with 🦀 by <a href="//www.visioncortex.org/">The Vision Cortex Research Group</a></sub>
<sub>Built with 🦀 by <a href="https://www.visioncortex.org/">The Vision Cortex Research Group</a></sub>
</div>
## Introduction
@@ -28,7 +28,7 @@ Comparing to Adobe Illustrator's [Image Trace](https://helpx.adobe.com/illustrat
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](//www.visioncortex.org/vtracer-docs).
A technical description of the algorithm is on [visioncortex.org/vtracer-docs](https://www.visioncortex.org/vtracer-docs).
## Web App
@@ -41,7 +41,7 @@ VTracer and its [core library](//github.com/visioncortex/visioncortex) is implem
## Cmd App
```sh
visioncortex VTracer 0.4.0
visioncortex VTracer 0.6.0
A cmd app to convert images into vector graphics.
USAGE:
@@ -71,30 +71,41 @@ OPTIONS:
-s, --splice_threshold <splice_threshold> Minimum angle displacement (degree) to splice a spline
```
### Usage
### Install
You can download pre-built binaries from [Releases](https://github.com/visioncortex/vtracer/releases).
You can also install the program from source from [crates.io/vtracer](https://crates.io/crates/vtracer):
```sh
cargo install vtracer
```
### Usage
```sh
./vtracer --input input.jpg --output output.svg
```
## Library
## Rust Library
The library can be found on [crates.io/vtracer](//crates.io/crates/vtracer) and [crates.io/vtracer-webapp](//crates.io/crates/vtracer-webapp).
## Install
Download pre-built binaries from [Releases](https://github.com/visioncortex/vtracer/releases).
or
Install from source (Rust toolchain needed):
You can install [`vtracer`](https://crates.io/crates/vtracer) as a Rust library.
```sh
cargo add vtracer
```
cargo install vtracer
## Python Library
Since `0.6`, [`vtracer`](https://pypi.org/project/vtracer/) is also packaged as Python native extensions, thanks to the awesome [pyo3](https://github.com/PyO3/pyo3) project.
```sh
pip install vtracer
```
## In the wild
VTracer is used by the following products (feel free to add yours to the list):
VTracer is used by the following projects (feel free to add yours!):
<table>
<tbody>
@@ -106,3 +117,15 @@ VTracer is used by the following products (feel free to add yours to the list):
</tr>
</tbody>
</table>
## What's next?
There are several things in my mind:
1. Pencil tracing. Instead of tracing shapes as closed paths, may be we can attempt to skeletonize the shapes as open paths. The output would be clean, fixed width strokes.
2. Perfect cut-out mode. Right now in cut-out mode, the shapes do not share perfect boundaries, but have seams.
3. Image cleaning. Right now the tracer works best on losslessly compressed pngs. If an image suffered from jpeg noises, it could impact the tracing quality. We might be able to develop a pre-filtering pass that denoises the input.
If you are interested in working on them or willing to sponsor its development, feel free to get in touch.
+7 -3
View File
@@ -1,6 +1,6 @@
[package]
name = "vtracer"
version = "0.6.0"
version = "0.6.1"
authors = ["Chris Tsang <chris.2y3@outlook.com>"]
edition = "2021"
description = "A cmd app to convert images into vector graphics."
@@ -13,9 +13,13 @@ keywords = ["svg", "computer-graphics"]
[dependencies]
clap = "2.33.3"
image = "0.23.10"
visioncortex = { version = "0.8.0" }
visioncortex = { version = "0.8.1" }
fastrand = "1.8"
pyo3 = { version = "0.19.0", optional = true }
[features]
python-binding = ["pyo3"]
python-binding = ["pyo3"]
[lib]
name = "vtracer"
crate-type = ["cdylib"]
+96
View File
@@ -0,0 +1,96 @@
<div align="center">
<img src="https://raw.githubusercontent.com/visioncortex/vtracer/master/docs/images/visioncortex-banner.png">
<h1>VTracer</h1>
<p>
<strong>Raster to Vector Graphics Converter built on top of visioncortex</strong>
</p>
<h3>
<a href="https://www.visioncortex.org/vtracer-docs">Article</a>
<span> | </span>
<a href="https://www.visioncortex.org/vtracer/">Demo</a>
<span> | </span>
<a href="https://github.com/visioncortex/vtracer/releases/latest">Download</a>
</h3>
<sub>Built with 🦀 by <a href="https://www.visioncortex.org/">The Vision Cortex Research Group</a></sub>
</div>
## 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](http://potrace.sourceforge.net/) 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](https://helpx.adobe.com/illustrator/using/image-trace.html), 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](https://www.visioncortex.org/vtracer-docs).
## Cmd App
```sh
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](https://github.com/visioncortex/vtracer/releases).
You can also install the program from source from [crates.io/vtracer](https://crates.io/crates/vtracer):
```sh
cargo install vtracer
```
### Usage
```sh
./vtracer --input input.jpg --output output.svg
```
## Rust Library
You can install [`vtracer`](https://crates.io/crates/vtracer) as a Rust library.
```sh
cargo add vtracer
```
## Python Library
Since `0.6`, [`vtracer`](https://pypi.org/project/vtracer/) is also packaged as Python native extensions, thanks to the awesome [pyo3](https://github.com/PyO3/pyo3) project.
```sh
pip install vtracer
```
+1 -1
View File
@@ -23,6 +23,6 @@ requires = ["maturin>=1.2,<2.0"]
build-backend = "maturin"
[tool.maturin]
features = ["pyo3/extension-module"]
features = ["pyo3/extension-module", "python-binding"]
compatibility = "manylinux2014"
sdist-include = ["LICENSE-MIT", "vtracer/README.md"]
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2020 Tsang Hao Fung. See the COPYRIGHT
// Copyright 2023 Tsang Hao Fung. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
+5 -3
View File
@@ -1,8 +1,10 @@
use vtracer::{Config, convert_image_to_svg};
mod config;
mod converter;
mod svg;
fn main() {
let config = Config::from_args();
let result = convert_image_to_svg(config);
let config = config::Config::from_args();
let result = converter::convert_image_to_svg(config);
match result {
Ok(()) => {
println!("Conversion successful.");