Skip to main content
filter · segment · trace

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.

stars
forks
C++/C/Py/JSbindings
Jupiter system montage raster image
raster input
Vectorized SVG output
svg output
View Example Apps

Use it anywhere

See all bindings
C++17

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)};

C++ DocsC Docs

Python

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)

Python Docs

JS

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();

JavaScript Docs

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