diff --git a/README.md b/README.md index eb8de67..9a00af2 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,9 @@

- Rust library on crates.io - CLI on crates.io - Python package on PyPI - Node package on npm + Rust library on crates.io + Python package on PyPI + Node package on npm

@@ -51,6 +50,13 @@ Technical descriptions of the [tracing algorithm](https://www.visioncortex.org/v ![screenshot](docs/images/desktop-app.png) +VTracer App features: + ++ Higher performance ++ Adaptive thresholding in B/W mode ++ Perfect cutout mode ++ Fixed color palette + ## Cmd App Input and output can be given as positional arguments or as named flags: @@ -103,9 +109,6 @@ Options: tessellation with shared boundaries), replacing the old re-clustered cutout. - **`--palette` / `--palette-file`** — snap colors to a fixed palette (nearest in OKLab); **`--max-colors`** auto-quantizes the palette. -- **`--optimize`** — output size passes (coordinate quantization, redundant- - point removal, relative/shorthand path encoding). Note: coordinate - precision is set separately by `--path-precision`, the bigger size lever. - **Binary thresholding** — a tunable fixed cutoff (`--threshold`) or **Bradley–Roth adaptive** thresholding (`--adaptive`, with `--adaptive-window` / `--adaptive-t`) for scans with uneven lighting. @@ -114,7 +117,7 @@ Options: 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): +You can also install the program from source: ```sh cargo install vtracer-cli @@ -146,15 +149,44 @@ cargo install vtracer-cli You can install [`vtracer`](https://crates.io/crates/vtracer) as a Rust library. ```sh -cargo add vtracer +cargo add vtracer@1.0.0-alpha.1 ``` +```rust +use vtracer::{ColorImage, Config, FitMode, Hierarchical, Preset, Session}; + +// Decode with whatever you like, then hand over pixels. +let raw = image::open("in.png")?.to_rgba8(); +let (width, height) = (raw.width() as usize, raw.height() as usize); +let img = ColorImage { pixels: raw.into_raw(), width, height }; + +// one-liner +let svg = Config::default().build()?.to_svg(&img)?; + +// presets + per-field config +let mut cfg = Config::from_preset(Preset::Poster); +cfg.mode = FitMode::Polygon; +cfg.hierarchical = Hierarchical::Cutout; // seam-free mosaic +cfg.max_colors = Some(8); +let svg = cfg.build()?.to_svg(&img)?; +``` + +Split the pipeline when you want the stages separately — `segment` caches, `finish` re-runs: + +```rust +let pipeline = cfg.build()?; +let seg = pipeline.segment(&img)?; // the expensive part +let doc = pipeline.finish(&seg)?; // VectorDoc, ready to serialize +``` + +See [docs.rs/vtracer](https://docs.rs/vtracer/1.0.0-alpha.1/vtracer/) for the full API. + ### Python Library -[`vtracer`](https://pypi.org/project/vtracer/) is also packaged as a Python native extension (built with [pyo3](https://github.com/PyO3/pyo3) + [maturin](https://www.maturin.rs), from the `crates/vtracer-py` crate). +[`vtracer`](https://pypi.org/project/vtracer/) is also packaged as a Python native extension. ```sh -pip install vtracer +pip install --pre vtracer ``` ```python @@ -182,7 +214,7 @@ See [`crates/vtracer-py`](crates/vtracer-py/README.md) for the full API. [`@visioncortex/vtracer`](https://www.npmjs.com/package/@visioncortex/vtracer) is available for Node as a WebAssembly build (from the [`nodejs`](nodejs/README.md) package) — image decoding and vectorization both run in wasm, so there is **no native dependency**. Decodes PNG, JPEG, GIF, BMP, and WebP; for other formats, decode yourself and pass raw RGBA to `convertPixels`. ```sh -npm install @visioncortex/vtracer +npm install @visioncortex/vtracer@1.0.0-alpha.1 ``` ```js diff --git a/crates/vtracer/Cargo.toml b/crates/vtracer/Cargo.toml index 69e1ace..c1819b5 100644 --- a/crates/vtracer/Cargo.toml +++ b/crates/vtracer/Cargo.toml @@ -9,6 +9,7 @@ homepage.workspace = true repository.workspace = true categories = ["graphics", "computer-vision"] keywords = ["svg", "vectorization", "computer-graphics"] +readme = "../../README.md" [lib] name = "vtracer" diff --git a/docs/images/desktop-app-dark.png b/docs/images/desktop-app-dark.png new file mode 100644 index 0000000..451d55c Binary files /dev/null and b/docs/images/desktop-app-dark.png differ diff --git a/docs/images/desktop-app-light.png b/docs/images/desktop-app-light.png new file mode 100644 index 0000000..ea1910f Binary files /dev/null and b/docs/images/desktop-app-light.png differ diff --git a/docs/images/desktop-app.png b/docs/images/desktop-app.png index bb4d608..0253625 100644 Binary files a/docs/images/desktop-app.png and b/docs/images/desktop-app.png differ