How to batch convert images to SVG
Converting one image to SVG is easy to check by eye. Converting five hundred is not: settings that suit one file ruin another, and a bad result can hide in the middle of the folder. This guide covers how to choose settings for a batch, the tools that can do it, and how to check the output.
Decide these before you start
- What the SVGs are for. Web and print want filled shapes; cutting machines want one layer per color; lasers want cut outlines. Pick one output per batch.
- How many colors. A fixed number gives consistent results across a product line. Let the tool decide if the images vary a lot.
- Exact colors, if they matter. For a brand or a product range, give the converter the palette instead of letting it measure colors from each image.
- What happens to the background. Keep it, remove it, or remove it only when it is a solid color.
- What a failure looks like. Decide how you will spot a bad result (too many colors, a huge file, a missing part) before you have hundreds to look through.
Option 1: a free script
If your images are clean (exported artwork, icons, line drawings), a local tracer in a loop is quick and free. The Python guide and the Node.js guide explain the settings. These are the loops:
from pathlib import Path
import vtracer
out = Path("svg")
out.mkdir(exist_ok=True)
for src in sorted(Path("images").iterdir()):
if src.suffix.lower() in {".png", ".jpg", ".jpeg"}:
vtracer.convert_image_to_svg_py(str(src), str(out / f"{src.stem}.svg"), filter_speckle=8)
print(f"{src.name} -> svg/{src.stem}.svg")import { mkdir, readdir, writeFile } from 'node:fs/promises';
import { promisify } from 'node:util';
import potrace from 'potrace';
const trace = promisify(potrace.trace);
await mkdir('svg', { recursive: true });
for (const file of await readdir('images')) {
if (!/\.(png|jpe?g)$/i.test(file)) continue;
const svg = await trace(`images/${file}`, { threshold: 128, turdSize: 2 });
await writeFile(`svg/${file.replace(/\.\w+$/, '')}.svg`, svg);
console.log(`${file} -> svg/${file.replace(/\.\w+$/, '')}.svg`);
}Where free tracers struggle is a mixed folder: some PNGs, some saved-from-the-web JPGs, some screenshots. In our test on low-quality JPEGs, VTracer at default settings kept a median of 133 colors per design, against the handful a design actually has. Settings tuned for those files then over-simplify the clean ones. Expect to sort the folder by source quality and run each group with its own settings.
Option 2: the SVG Me API
The API rates each image’s source quality and picks settings per image, so one call works on a mixed folder. You still set what should be consistent across the batch:
colors=4, orpalette=#1d3557,#e63946,#f1faeeto force exact colors on every image.remove_background=autoremoves a solid background only where there is one.format=layers,outlineorsticker, andfile_type=pdf,epsordxffor the output.
The API guide has ready-made folder scripts for the shell, Node.js and Python that retry rate limits and report failures without stopping. A batch of 200 images costs $20 with the 200-credit pack; failed conversions cost nothing.
Run the first ten images, check them, then run the rest. Getting the same image again in another format, or converting it again with the same settings, is free.
Checking the results
You don’t need to open every file. Sort the output and look at the outliers:
- The largest files. A file several times the size of the rest usually means the image was a photo, or noise turned into thousands of shapes.
- The color count. Count the distinct
fillvalues in each SVG. An image with far more colors than you asked for, or with only one, needs a look. - A contact sheet. Render all the SVGs into one grid image (ImageMagick’s
montagedoes it in one command) and scan it for missing parts and wrong colors. - The machine test. For cut files, cut one or two before running the whole batch through your cutter or laser.
Questions
Can Inkscape batch convert images to SVG?
Inkscape’s Trace Bitmap is a dialog, so tracing a folder means opening each image. You can script Inkscape, but at that point running Potrace (the engine behind Trace Bitmap) or VTracer directly is simpler.
How long does a batch take?
Local tracers take well under a second per clean image on a laptop, and longer for large or noisy ones. The API usually takes a few seconds per image, two at a time per account.