Bitmap to Pixelated SVG Converter
Convert bitmap images (PNG, GIF, JPG) to crisp, scalable SVG files with edge-tracing optimization. Preserve pixel sharpness at any size.
About
Scaling bitmap pixel art in browsers produces blurry results. CSS image-rendering: pixelated remains inconsistent across engines. SVG is the only static format that guarantees crisp pixel boundaries at arbitrary scale factors. This tool reads raw RGBA data from any raster image via the Canvas API, quantizes colors within a configurable Euclidean distance threshold d = √Δr2 + Δg2 + Δb2, then emits optimized SVG paths. The edge-tracing algorithm merges adjacent same-color pixels into minimal rectangles or contour paths, reducing output file size by 60 - 90% compared to naive one-rect-per-pixel approaches.
Limitations: this tool approximates transparency as a binary threshold (α < 128 is transparent). Anti-aliased edges in source bitmaps will produce extra quantized color bands. For best results, use source images with hard pixel edges and no anti-aliasing. Maximum supported input is 2048 × 2048 px. Processing time scales with pixel count and unique color count.
Formulas
Color distance between two pixels is computed using Euclidean distance in RGB space. Pixels with distance below the tolerance threshold are quantized to the same color.
Where r, g, b are the red, green, and blue channel values in the range [0, 255]. Maximum possible distance is √3 × 2552 ≈ 441.67.
Transparency is determined by alpha threshold:
SVG viewBox is set to native pixel dimensions. Each pixel maps to a 1 × 1 unit in SVG coordinate space. Scaling is handled by the SVG viewport, preserving crispness at any display size.
The greedy rectangle merge algorithm scans each row left-to-right, creating horizontal runs of identical color. Adjacent rows with identical run patterns are merged vertically. Complexity is O(W × H) per color.
The path trace algorithm builds a binary grid per color, then traces the outer contour using direction vectors. It produces a single <path> d attribute with M, h, v, and Z commands. Interior holes are traced as separate sub-paths with reversed winding.
Reference Data
| Optimization Mode | Method | SVG Elements | File Size | Best For |
|---|---|---|---|---|
| None (1:1 Rects) | One <rect> per pixel | W × H | Largest | Debugging, exact fidelity |
| Row Merge | Merge horizontal runs | ≈ 30−50% reduction | Medium | Simple sprites |
| Rect Merge (Greedy) | Merge rows then columns | ≈ 60−80% reduction | Small | Pixel art, icons |
| Path Trace | Contour tracing per color | 1 <path> per color | Smallest | Few-color pixel art |
| Input Format | MIME Type | Alpha Support | Animation | Notes |
|---|---|---|---|---|
| PNG | image/png | Yes (8-bit) | No (APNG ignored) | Best input format |
| GIF | image/gif | 1-bit only | First frame only | Classic pixel art format |
| JPEG | image/jpeg | No | No | Lossy artifacts add colors |
| BMP | image/bmp | Varies | No | Uncompressed, large files |
| WebP | image/webp | Yes | First frame only | Browser support varies |
| Preset | Scale | Optimization | Color Tolerance | Use Case |
|---|---|---|---|---|
| Pixel Art 1× | 1 | Rect Merge | 0 | Exact reproduction |
| Retro Icon 2× | 2 | Path Trace | 10 | Favicons, small icons |
| Favicon 4× | 4 | Path Trace | 5 | Browser tab icons |
| Sprite Sheet | 1 | Path Trace | 0 | Game sprite export |
| Logo 8× | 8 | Rect Merge | 15 | Large display logos |