command-line reference
Documentation
Everything you need to trace a PNG into an SVG from the terminal. The command is
potrace; point it at an image and it prints SVG.
Install
Prebuilt binary
Download the latest CI build, unpack, and put it on your PATH:
$ tar -xzf potrace-macos-arm64.tar.gz
$ ./potrace --input image.png --output image.svg Usage
$ potrace --input <file.png> [--output <file.svg>] [options] Core options
| Flag | Description | Default |
|---|---|---|
-i, --input <file> | Input PNG file path. | required |
-o, --output <file> | Output SVG file path. | stdout |
| --invert | Invert the input image colours before tracing. | false |
--turdsize <n> | Suppress speckles whose area is at or below this many pixels². | 2 |
--alphamax <n> | Corner threshold. 0 keeps every corner crisp; 1.34 rounds everything. | 1.0 |
Anti-aliasing options
Anti-aliasing softens 1-bit stair-stepping before tracing. Turn it on with
--anti-alias; the rest only matter once it is enabled.
| Flag | Description | Default |
|---|---|---|
| --anti-alias | Smooth pixelated edges by anti-aliasing the bitmap before tracing. | false |
--anti-aliasing-algorithm <gaussian|supersample> | Which anti-aliasing strategy to use. | gaussian |
--anti-alias-sigma <n> | Gaussian blur sigma (≥ 0). | 0.8 |
--anti-alias-kernel-size <n> | Gaussian kernel size — odd and ≥ 3. | 3 |
--anti-alias-threshold <n> | Post-blur re-binarisation threshold in [0, 1]. | 0.5 |
--anti-alias-supersample-factor <n> | Supersampling factor — integer ≥ 2. | 2 |
Example commands
Trace to a file
$ potrace --input image.png --output image.svg Trace to stdout (pipe it)
$ potrace --input image.png > image.svg Invert before tracing
$ potrace -i image.png -o image.svg --invert Drop small speckles
$ potrace -i image.png -o image.svg --turdsize 8 Gaussian anti-aliasing
$ potrace -i image.png -o image.svg --anti-alias --anti-aliasing-algorithm gaussian Supersample 4×
$ potrace -i image.png -o image.svg --anti-alias \
--anti-aliasing-algorithm supersample --anti-alias-supersample-factor 4