Skip to main content

A professional Image to SVG converter with background removal and multi-color support.

Project description

🖼️ Suresh SVG Converter

A professional, production-ready Python package for removing backgrounds from images and converting them to high-quality multi-color SVG format.

PyPI version License: MIT

✨ Features

  • Background Removal: AI-powered background removal using rembg with ONNX runtime.
  • Accurate SVG Conversion: High-quality vector tracing using potrace with 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 performance
  • REMBG_MODEL: Choose between u2net, u2netp, etc.

📝 License

MIT License - See LICENSE file for details.

🙏 Acknowledgments


Built with ❤️ for the developer community.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

suresh_svg_converter-0.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

suresh_svg_converter-0.1.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file suresh_svg_converter-0.1.0.tar.gz.

File metadata

  • Download URL: suresh_svg_converter-0.1.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for suresh_svg_converter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40b1f9dd24c455bb3fefd9bd9dd2e681af8963819e902b1efcc8bcb41c87152b
MD5 0c542422ca10af84bd9fafa82397f94b
BLAKE2b-256 295ac51ddc7ffaefd8738021d88dc3253169dac590edace3a9084e92a7464e91

See more details on using hashes here.

File details

Details for the file suresh_svg_converter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for suresh_svg_converter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6c4e00ee050106881fcbcf6751c48addbdd8b45b385a07b28066093c5288462
MD5 be65a1ecdd4ebd5774c17967d2bdfea2
BLAKE2b-256 f14dd8234a307bfe0e0aeca96efe835a91f9f1f9c5799f260028ce5b1a3fcf7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page