| Crates.io | pngtosvg |
| lib.rs | pngtosvg |
| version | 0.5.0 |
| created_at | 2025-12-08 09:20:13.715834+00 |
| updated_at | 2025-12-08 13:22:15.766108+00 |
| description | A CLI tool and library to convert PNG images into SVG vectors. |
| homepage | |
| repository | https://github.com/mayuso/PNGToSVG |
| max_upload_size | |
| id | 1973038 |
| size | 56,244 |
PNGToSVG is a high-performance tool written in Rust that converts PNG raster images into SVG vectors.
Note: This project has been rewritten in Rust for speed and portability. If you are looking for the original Python prototype, please check the
/legacy_pythondirectory.
.exe for Windows).Ensure you have Rust installed.
git clone https://github.com/mayuso/PNGToSVG.git
cd PNGToSVG
cargo build --release
The binary will be available in ./target/release/.
Easiest for single files or quick conversions.
pngtosvg.exe..png files (or a folder containing PNGs).pngtosvg.exe icon.Best for automation and power users.
Convert a single file:
pngtosvg image.png
Convert a specific folder:
pngtosvg ./assets/icons/
Convert current directory:
pngtosvg .
Note for Linux/macOS users: If you haven't added the binary to your
PATH, you will need to prefix the command with./(e.g.,./pngtosvg image.png) while inside the directory containing the executable.
Add the dependency to your project:
cargo add pngtosvg
Use this to convert your file directly from a path:
use pngtosvg::convert_file_to_svg;
use std::path::Path;
fn main() {
let input_path = Path::new("image.png");
match convert_file_to_svg(input_path) {
Ok(svg_content) => {
println!("Generated SVG:\n{}", svg_content);
// You can write svg_content to a file here
}
Err(e) => eprintln!("Error converting file: {}", e),
}
}
Use this if you already have an image::RgbaImage (e.g., from generated content or WASM):
use pngtosvg::rgba_image_to_svg_contiguous;
use image::RgbaImage;
fn main() {
// Assume you have an RgbaImage from somewhere
let img = RgbaImage::new(100, 100);
// Convert directly to SVG string
let svg_content = rgba_image_to_svg_contiguous(&img);
println!("{}", svg_content);
}
The original Python implementation is kept in this repository for educational purposes and as a reference logic implementation. It is no longer actively maintained.
To use the legacy version:
legacy_python folder.pip install -r requirements.txtpython main.pyA dry run verifies everything compiles and packs correctly (I do this before publishing the package)
cargo publish --dry-run