How ryan-millard/img2num works
Img2Num is a raster-to-SVG vectorizer designed especially for natural images. Its main workflow takes raster pixels through color reduction and contour processing, then emits layered SVG paths; users can reach the native core through C or Python bindings, or JavaScript through WebAssembly. The graph also preserves the documented GPU path. The README documents the core stages and language support; sampled source confirms the contour and WASM-client responsibilities, but does not expose the complete native call chain.
Main entry points: img2num.h C++ API · kmeans.cpp Color Quantization · cimg2num.cpp C Binding · img2num_pybind.cpp Python Binding
Components 16
Language Interfaces
- C++ API
core/include/img2num.h - C Binding
bindings/c/src/cimg2num.cpp - Python Binding
bindings/py/src/img2num_pybind.cpp - JavaScript API
packages/js/src/index.js - WASM Client
packages/js/src/wasmClient.js - WASM Bridge
bindings/js/src/wasm_wrapper.c
Vectorization Core
- Color Model
core/include/internal/cielab_impl.h - Image Filtering
core/src/internal/bilateral_filter.cpp - Color Quantization
core/src/internal/kmeans.cpp - Contour Extraction
core/src/internal/contours.cpp - Polygon Simplification
core/src/internal/douglas_peucker.cpp - SVG Generation
core/src/internal/image_to_svg.cpp - Labeled SVG
core/src/internal/labels_to_svg.cpp
GPU Processing
- GPU Quantization
core/src/internal/kmeans_gpu.cpp - WebGPU Runtime
core/include/internal/gpu.h
Other components
- Image User
Connections 18
- Image User → C++ API: provides pixels
README.md - Image User → C Binding: uses binding
README.md - Image User → Python Binding: uses binding
README.md - Image User → JavaScript API: uses package
README.md - JavaScript API → WASM Client: invokes
- WASM Client → WASM Bridge: calls exports
- C Binding → C++ API: forwards requests
- Python Binding → C++ API: forwards requests
- WASM Bridge → C++ API: forwards requests
- C++ API → Image Filtering: filters image
- C++ API → Color Quantization: reduces colors
README.md - Color Quantization → Color Model: uses color model
- Color Quantization → GPU Quantization: accelerates with
- GPU Quantization → WebGPU Runtime: uses WebGPU
- C++ API → Contour Extraction: extracts contours
README.md - Contour Extraction → Polygon Simplification: simplifies paths
README.md - C++ API → SVG Generation: writes SVG
README.md - C++ API → Labeled SVG: writes labeled SVG
README.md