Skip to content

everyer2009/SquareKoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐟 SquareKoi

Nedda & CC's SVG Converter β€” turn pixel art and flat-color images into true vector SVG, point by point.

No Inkscape. No embedded bitmaps pretending to be vectors. Every pixel becomes a real <rect>, merged into clean shapes, grouped by color β€” an SVG you can scale to a billboard.

Why

Most "image to SVG" exports just wrap your PNG inside an <image> tag (still a bitmap), and most tracers smear pixel art into wobbly paths. SquareKoi does the honest thing: it scans your image pixel by pixel and rebuilds it as crisp vector rectangles.

Features

  • 🎨 Color quantization β€” reduce to 8 / 16 / 32 / 64 / custom colors (median-cut), kills anti-aliasing noise
  • πŸͺ„ Auto pixel-grid detection β€” pixel art exported at 2x/10x is detected (GCD-based) and shrunk back to its logical resolution: dramatically smaller files
  • πŸ‘» Two transparency modes β€” native PNG alpha is preserved (unpainted = transparent), or chroma-key any background color away (auto samples the corners)
  • πŸ“¦ Batch or single β€” drop a folder of frames, get a folder of SVGs
  • πŸ–₯️ Double-click launchers for macOS & Windows (native dialogs, no server, no port) + full CLI
  • πŸ›‘οΈ Complexity guardrail β€” refuses to emit a 30 MB monster for a photo, tells you what to do instead
  • Zero dependencies except Pillow

Quick start

Double-click launchers (the cozy way)

  • macOS β€” double-click SquareKoi.command
  • Windows β€” double-click SquareKoi.bat (needs Python 3 with "Add to PATH" checked)

Native dialogs walk you through it:

  1. Pick images (multi-select OK) β€” or a whole folder for batch
  2. Pick a color tier (Original / 8 / 16 / 32 / 64 / custom)
  3. Pick background handling (PNG transparency / auto remove / custom color)
  4. Done β€” the out/ folder pops open with your SVGs ✨

Windows launcher note: dialogs are PowerShell 5.1 native; if your art comes out odd, try the CLI and open an issue.

CLI (the scriptable way)

pip install pillow

python3 img2svg.py                          # convert everything in in/ -> out/
python3 img2svg.py sprite.png               # single file
python3 img2svg.py art.png --colors 16      # quantize to 16 colors
python3 img2svg.py photo.jpg --key auto     # auto-remove background color
Option Default What it does
--colors N 0 (off) Quantize palette to N colors (median-cut)
--pixel auto|N auto Detect & shrink the pixel grid (or force block size N)
--key auto|'#rrggbb' off Chroma-key a background color to transparency
--key-tol N 40 Chroma-key color distance tolerance
--alpha N 128 Alpha below this is treated as transparent
--max-rects N 50000 Complexity guardrail

How it works

  1. Transparency first β€” alpha & chroma-key are resolved on the original colors (quantizing first would shift colors and break the key)
  2. Quantize β€” masked areas are flattened to one palette slot so your actual artwork gets the full color budget
  3. Grid detection β€” the GCD of all row/column change positions gives the largest lossless pixel block; the image is shrunk back with per-block majority vote
  4. Rect merging β€” horizontal runs of identical color become one <rect>, identical runs stack vertically into taller rects
  5. Output β€” rects grouped per color under <g fill>, integer coordinates, shape-rendering="crispEdges"

Pixel-art sweet spot: a 16Γ—16 sprite exported at 192Γ—192 β†’ 17 rects, 3 colors, 0.9 KB.

File-size rule of thumb (measured on an anti-aliased 268Γ—175 sprite): beyond 8 colors, each doubling of the palette costs roughly +50–60% file size. Clean pixel art is unaffected β€” its real palette is already tiny.

Not for photos

Continuous-tone images (photos, gradients) don't belong in rect-SVG land. The guardrail will stop you. A tracing mode (vtracer-style paths) may come later.

License

MIT


Made with β™₯ by Nedda & CC β€” born the day we needed 11 koi-fish animation frames as vectors.

About

Turn pixel art & flat-color images into true vector SVG β€” point by point. 🎏 by Nedda & CC

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors