YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
πΌοΈ Suresh SVG Converter
A professional, production-ready Python package for removing backgrounds from images and converting them to high-quality multi-color SVG format.
β¨ Features
- Background Removal: AI-powered background removal using
rembgwith ONNX runtime. - Accurate SVG Conversion: High-quality vector tracing using
potracewith multi-color support. - Color Quantization: Automatically detects dominant colors and creates stratified SVG layers.
- Dual Interface: Full-featured Command Line Interface (CLI) and a beautiful FastAPI web UI.
- CPU Optimized: Runs entirely on CPU with no GPU dependency.
- Fast Performance: Optimized for speed with lazy model loading and K-Means quantization.
- Batch Processing: Process multiple images at once via CLI.
π Requirements
- Python 3.9+
- 2GB+ RAM recommended for high-resolution processing.
π Installation
Install the package directly from PyPI:
pip install suresh-svg-converter
π₯οΈ Usage
Command Line Interface (CLI)
Once installed, use the suresh-svg-converter command anywhere:
Basic usage:
suresh-svg-converter input.jpg
With options:
# Convert with 16 colors and remove background
suresh-svg-converter input.png --remove-bg --colors 16
# Custom output directory
suresh-svg-converter *.png -o ./results
# Batch process multiple files
suresh-svg-converter img1.jpg img2.webp img3.png
CLI Options:
--remove-bg, -r: Remove background (default: enabled)--colors, -c: Number of colors for SVG tracing (default: 8)--output-dir, -o: Custom output directory--max-dim: Maximum image dimension for processing (default: 4096)--verbose, -v: Enable verbose logging
Web Interface
Launch the interactive web UI to drag and drop images:
python -m suresh_svg_converter.main
Or use uvicorn directly:
uvicorn suresh_svg_converter.main:app --host 0.0.0.0 --port 8000
Then open http://localhost:8000 in your browser.
Programmatic API
Use the converter in your own Python projects:
from suresh_svg_converter.services.svg_convert import SVGConverter
from suresh_svg_converter.services.bg_remove import BackgroundRemover
from PIL import Image
# Load image
img = Image.open("photo.jpg")
# Remove background
remover = BackgroundRemover()
img_no_bg = remover.remove_background(img)
# Convert to SVG with 12 colors
converter = SVGConverter()
svg_path = converter.convert(img_no_bg, "output.svg", num_colors=12)
print(f"Vector saved to: {svg_path}")
π Project Structure
suresh_svg_converter/
βββ cli.py # Main CLI entry point
βββ main.py # FastAPI web application
βββ config.py # Configuration settings
βββ services/
β βββ bg_remove.py # Background removal service
β βββ svg_convert.py # Multi-color SVG conversion
β βββ image_utils.py # Image preprocessing
βββ routes/
β βββ upload.py # API routes
βββ models/
βββ image_models.py # Data schemas
βοΈ Configuration
You can customize the default behavior in suresh_svg_converter/config.py:
SVG_DEFAULT_COLORS: Default number of color layers (default: 8)MAX_IMAGE_DIMENSION: Resize limit for performanceREMBG_MODEL: Choose betweenu2net,u2netp, etc.
π License
MIT License - See LICENSE file for details.
π Acknowledgments
Built with β€οΈ for the developer community. # suresh-svg-converter