Foto in SVG-Vektorgrafik verwandeln
Verwandelt ein Foto automatisch in eine skalierbare SVG-Vektorgrafik — perfekt für Logos, Drucke oder beliebige Größen ohne Qualitätsverlust. Voreingestellt auf eine sinnvolle Balance zwischen Farbtreue und schlanker SVG-Datei.
INPUT
Vector (SVG)
Raster (downscaled)
JavaScript
// Raster → SVG tracing via vtracer
// demo_vectorize.js
//!OUTPUT: OUTPUT_SVG,OUTPUT
// demo_vectorize.js — Convert a raster image to SVG using vtracer
//
// Usage (CLI):
// Engine.loadImage("path/to/input.png") + Engine.writeSVG("out.svg", svg)
//
// The script resizes the image first to keep the SVG manageable,
// then traces with sensible defaults for photographic content.
const src = Engine.loadImage(INPUT);
// Resize to a fixed width for predictable tracing complexity
const W = 256;
const scale = W / src.width;
const H = Math.round(src.height * scale);
const small = src.clone().resize(W, H);
// Trace to SVG
const svg = small.toSVG({
filterSpeckle: 4, // ignore regions < 4 px
colorCount: 16, // up to 16 color layers
pathSimplify: "spline",
hierarchical: "stacked",
cornerThreshold: 60,
lengthThreshold: 4.0,
maxIterations: 10,
spliceThreshold: 45,
});
// Write to output
Engine.writeSVG("OUTPUT_SVG", svg);
// Also save the (scaled) raster for comparison
Engine.saveImage(small, "OUTPUT");
`Vectorized: ${src.width}×${src.height} → SVG (${svg.length} chars)`;
// © 2026 Michael Lechner · mlc OpticScript · https://mlcgo.eu · Elastic License 2.0