Raster to SVG
in C++, Python,
JavaScript & C
Img2Num is a cross-platform library that converts PNG/JPEG to clean, layered SVG paths. Built for speed, zero dependencies, and multi-language bindings.

Use it anywhere
See all bindings →Native speed
Quantisation, contour tracing, SVG writer. Add it as a submodule.
#include "img2num"
img2num::ImageToSvgConfig config;
config.kmeans.k = 32;
std::string svg {img2num::image_to_svg(img_data, width, height, config)};pip install img2num
Numpy array in → SVG string out. Seamless integration.
import img2num
cfg = img2num.ImageToSvgConfig(kmeans = {"k": 16})
svg = img2num.image_to_svg(img, config=cfg)npm i img2num
Browser / Node. Same C++ core compiled to WebAssembly.
import { imageToUint8ClampedArray, imageToSvg } from "img2num"
const { pixels, width, height } = await imageToUint8ClampedArray(file);
const svg = await imageToSvg({ pixels, width, height });Designed for developers
Precise contour extraction
Edge detection & polygon simplification with tunable fidelity.
Colour quantization + palette
Automatically reduce colours to any K value, output SVG with groups.
Zero-copy bindings
Direct memory access in Python (numpy) and JS (TypedArray).
Cross-platform CI
Tested on Linux, macOS, Windows, and WASM in CI.
Ready to integrate SVG vectorization into your stack?
Get started →Ecosystem
C++ API Reference ➚
Full reference, parameter tuning, build instructions.
img2num on PyPI ➚
pip install img2num, examples notebook.
img2num ➚
Node.js and browser ready.
Conan Center ➚
C++ package manager integration.
GitHub issues ➚
Report bugs, request bindings, contribute.
MIT ➚
Permissive, commercial friendly.