Skip to main content
vectorize · quantize · export

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.

stars
forks
C++/C/Py/JSbindings
Jupiter system montage raster image
raster input
Vectorized SVG output
svg output
Try Live Demo →

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)

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

JsDoc

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