| Crates.io | pix2svg |
| lib.rs | pix2svg |
| version | 0.1.0 |
| created_at | 2025-06-04 05:08:13.574325+00 |
| updated_at | 2025-06-04 05:08:13.574325+00 |
| description | Convert pixel art images to optimized SVG format |
| homepage | |
| repository | https://github.com/LeSnow-Ye/pix2svg |
| max_upload_size | |
| id | 1699800 |
| size | 343,389 |
Warning: This project is mainly created by GitHub Copilot with Claude Sonnet 4. Not fully reviewd and tested yet. Use it at your own risk. PRs and issues are welcome.
A fast and efficient command-line tool to convert pixel art images to optimized SVG format with greedy rectangle merging.
git clone https://github.com/LeSnow-Ye/pix2svg.git
cd pix2svg
cargo build --release
The binary will be available at target/release/pix2svg.
cargo install pix2svg
# Convert image.png to image.svg
pix2svg image.png
# Specify output file
pix2svg image.png -o output.svg
# Scale pixels by 4x
pix2svg image.png -s 4
# Enable verbose output
pix2svg image.png -v
# Convert with custom alpha threshold
pix2svg image.png --alpha-threshold 128
# Scale up and specify output
pix2svg sprite.png -s 8 -o large-sprite.svg -v
input: Input image file path-o, --output: Output SVG file path (default: input filename with .svg extension)-s, --scale: Pixel scale factor (1-1000, default: 1)--alpha-threshold: Minimum alpha threshold for non-transparent pixels (0-255, default: 1)--skip-transparent: Skip transparent pixels (default: true)-f, --force: Force overwrite existing output files-v, --verbose: Enable verbose output-h, --help: Show help informationThe tool uses a greedy rectangle merging algorithm similar to the one used in Aseprite:
<rect> elements for each rectangleThis approach significantly reduces the number of SVG elements compared to naive pixel-by-pixel conversion.
Source: CC-29 Palette
464x120 = 55680 pixels

4738 rectangles (8.51%)
This project is licensed under the MIT License - see the LICENSE file for details.