Expand description
§pix2svg
A fast and efficient library to convert pixel art images to optimized SVG format.
§Features
- Optimized Output: Uses greedy rectangle merging algorithm to minimize SVG file size
- Multiple Formats: Supports PNG, JPEG, GIF, BMP, and other common image formats via the
imagecrate - Transparency Support: Handles transparent pixels with configurable alpha threshold
- Pixel Scaling: Scale up pixel art with crisp edges
- Fast Processing: Optimized rectangle merging for efficient conversion
§Quick Start
use pix2svg::{convert_image_to_svg, ConversionOptions};
use image;
// Load an image
let img = image::open("pixel_art.png")?;
// Configure conversion options
let options = ConversionOptions {
scale: 4,
alpha_threshold: 1,
..Default::default()
};
// Convert to SVG
let svg_content = convert_image_to_svg(&img, options)?;
// Save to file
std::fs::write("output.svg", svg_content)?;Structs§
- Color
- Represents a color with RGBA components
- Conversion
Options - Configuration options for SVG conversion
- Conversion
Result - Conversion result containing SVG content and statistics
- Rectangle
- Represents a rectangle with position, size, and color
Functions§
- convert_
file_ to_ svg - Convert image file path to SVG format
- convert_
image_ to_ svg - Convert a dynamic image to SVG format with given options
- save_
svg_ to_ file - Save SVG content to a file
- save_
svg_ to_ file_ safe - Save SVG content to a file with overwrite protection