Potrace Turn Policy: Trace Separate Diagonal Paths
Compare Potrace black, white, and minority turn policies on two pixel blocks that touch at a corner. Check which setting gives you separate SVG paths.
On this page
Potrace’s turn policy decides how the tracer follows a boundary when dark and light pixels meet diagonally at one grid corner. Use --turnpolicy white to favor the light connection at that corner, or --turnpolicy black to favor the dark connection. Keep the source mask fixed while comparing them. Potrace command reference
Two traces can look alike and still contain different numbers of paths. That matters when a pair of marks needs to remain separately selectable or when the light space between them needs to survive later edits.
Identify the ambiguous corner
Draw a 2 × 2 grid. Put black squares at the upper left and lower right, and white squares in the other two cells. All four cells touch at the center vertex. The boundary can turn there in either direction, which changes which color stays connected across the corner. The Potrace algorithm paper explains this path-decomposition step.
| Setting | What it favors at an ambiguous corner |
|---|---|
black | A connection between black pixels |
white | A connection between white pixels |
minority | The locally less common color. This is Potrace’s default. |
majority | The locally more common color |
The fixed left and right policies choose a turn direction. Start with black and white when your design gives you a clear foreground or background preference.
Trace one bitmap with the same settings
The test uses Potrace and a plain-text PBM, a monochrome bitmap format. In PBM, 1 means black and 0 means white. Save this as corner.pbm. Its two 5 × 5 blocks meet at one corner. Netpbm PBM specification
P1
12 12
0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0for policy in black white minority; do
potrace corner.pbm --svg --turnpolicy "$policy" \
--turdsize 0 --alphamax 0 --output "$policy.svg"
doneThe two fixed flags keep the corner comparison simple. --turdsize 0 disables speckle removal, and --alphamax 0 makes the output polygonal. Compare the saved SVGs in the same editor and expand their group in the object list. Alternatively, open them as text and count the <path> elements for this fixture.
In Potrace 1.16, black and minority each produced one closed path. White produced two independently selectable closed paths. Both white paths retain the corner point in this test, so they can still look like they touch. Use a geometric gap in the input if the deliverable requires physical separation.

Diagnose a merge that persists
Check the thresholded bitmap first. If the dark shapes already share a pixel edge, the turn policy cannot create a gap there. Clean up that border in the bitmap or adjust the threshold, then rerun your comparison. The Potrace PNG preparation guide covers the conversion from PNG to a mask. If two shapes still look like one, use the trace quality checklist to inspect the exported objects and openings.
FAQ
What is Potrace’s default turn policy?
Potrace defaults to minority. At an ambiguous corner, it favors the color that occurs less often in the local neighborhood.
Can turn policy change a shape where pixels share an edge?
Turn policy resolves ambiguous turns at a boundary vertex. To split shapes already joined along an edge, change the mask so they have separate boundaries.
Does the white policy create clearance between two shapes?
It can produce separate paths for corner-touching dark areas. In this sample, those paths still touch at a point. For positive clearance, introduce a gap in the source and measure it in the output.
Start with the original raster
PerfectVector can trace a raster image into editable vector paths.
If you have only the original PNG or JPG, preview a vector trace and check the corner at zoom. Inspect the path list before you decide whether the marks need to be drawn apart.
Sources
- Potrace command reference — Turn-policy values, defaults, and tracing flags.
- Peter Selinger, Potrace algorithm paper — Ambiguous grid vertices and path decomposition.
- Netpbm PBM specification — Pixel values and the plain PBM input format.
More from the blog
Tune Potrace Curve Tolerance for Simpler SVG Paths
Compare Potrace opttolerance with longcurve on the same bitmap. Count cubic segments in each SVG and check what changes along the outline.
VTracer PNG to SVG: Check Colors and Small Details
Convert a PNG with the tested VTracer CLI, compare palette and speckle settings, and inspect which colors and small regions remain in the actual saved SVG.


