Skip to content
All SVG guides

AI & tracing

Understanding Tracing: Raster PNG to Scalable Vector Graphics

A raster image is a fixed grid of coloured pixels, so enlarging it blurs or pixelates it. A vector image — an SVG — describes the drawing as paths: lines and curves between points, redrawn at whatever size is needed. Tracing is the step that turns the first into the second.

This article covers the algorithmic mechanics of image vectorisation — how a raster bitmap is mapped, processed and traced into scalable coordinates. It describes how edge tracers work in general, not how any one tool is built.

1. Algorithmic Steps in Image Tracing

Transforming a raster bitmap into a mathematical path relies on three sequential calculations:

  1. Colour quantisation: reduces the millions of colours in a PNG or JPEG to a small palette of distinct colours. This merges noisy details and unifies backgrounds.
  2. Edge detection: scans neighbouring pixel groups to identify high-contrast boundaries. This locates the shapes' contours and draws temporary edge points.
  3. Path fitting: fits cubic or quadratic Bézier curves around the edge coordinates, using mathematical algorithms (such as the Potrace method) to calculate control points with minimum node counts.

2. Understanding Bezier Curve Formulations

SVGs use cubic bezier curves via the C operator inside standard path descriptions. The formula is:

C x1 y1, x2 y2, x y

Here, x1, y1 represent the first control node (handles curve slope at start), x2, y2 represent the second control node (handles slope at end), and x, y is the target end anchor point.

3. Vector Code Example: Traced Circle

An algorithmic trace of a simple circular outline renders path components rather than standard circle elements to match complex contours:

traced_circle.svg
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <!-- Traced Circle Path -->
  <path d="M 50 10 
           C 72.09 10, 90 27.91, 90 50 
           C 90 72.09, 72.09 90, 50 90 
           C 27.91 90, 10 72.09, 10 50 
           C 10 27.91, 27.91 10, 50 10 Z" 
        fill="#e0f2fe" stroke="#0284c7" stroke-width="2" />
</svg>

4. Where tracing works, and where it does not

Tracing suits flat, high-contrast artwork — logos, line art, scanned ink. On photographs it produces thousands of paths that are larger and slower than the JPEG they came from: a 16-colour photo written out as vector shapes measured more than nineteen times the size of the matching PNG. The settings that matter are the number of colours the quantiser keeps and how far the curve fitter may smooth a corner. Fewer colours and more smoothing mean fewer paths and a smaller file, at the cost of detail.

One thing to know before you upload: SVG Maker AI's PNG to SVG tool does not trace. A vision model describes the image and a new SVG is generated from that description, so the result resembles the original rather than following its edges. For a logo that must match exactly, use an edge tracer such as Potrace or Inkscape's Trace Bitmap, or redraw it. The difference between the two routes is set out in PNG to SVG: tracing or redrawing.

ShareLinkedInXReddit