Raster to SVG
in C++, Python,
JavaScript & C
Img2Num is a cross-platform raster-to-SVG conversion library - it converts bitmap images like PNGs and JPEGs into clean, scalable SVG paths. Built for speed, minimal dependencies, and multi-language bindings.

Use it anywhere
See all bindingsNative 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 });
await terminateWasmModule();
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 startedEcosystem
C++ API Reference ➚
Full reference, parameter tuning, build instructions.
img2num on PyPI ➚
pip install img2num, examples notebook.
img2num ➚
Node.js and browser ready.
GitHub issues ➚
Report bugs, request bindings, contribute.
MIT ➚
Permissive, commercial friendly.
Changelog ➚
Stay up to date with the latest changes Img2Num.