How Image Tracing Works

A tracer looks at a grid of pixels and draws the shapes it thinks the pixels were meant to show. This page follows our own engine through that job, with the numbers it produces on the sample images you can load in any tool on this site.

Measured in Chromium 140 · Compared with four other engines

A trace is a redrawing

A PNG or JPG records a color for every pixel and nothing about shapes. An SVG records shapes: a path, its curves and one fill color. Nothing in the pixels says where one shape stops and the next begins, so no program can translate one into the other the way it re-encodes a PNG as a JPG. A tracer has to decide which pixels belong together and then draw an outline around each group. When the picture really is a few areas of solid color, that decision is easy and the drawing is close to exact. When it is a photograph, every decision is a guess.

What our engine does, in order

  1. Reads the image at a working size. The page opens files up to 2,400 px on the long side and traces at 1,200 px. Smaller images are enlarged first, up to 8 times, so curves have room to be smooth.
  2. Finds the real colors. It groups the pixels by color, measured the way the eye tells colors apart, and then discards any group that only ever appears as a thin band between two others. Those bands are the blur along edges and the color bleed a JPEG leaves, never artwork.
  3. Gives every pixel to one of those colors. A blended edge pixel goes to one of the two colors it mixes. When the image is being enlarged, each edge pixel also says how much of each color it holds, which places the edge inside the pixel instead of on its border.
  4. Traces each area into curves. VTracer 1.0, an open-source engine compiled to WebAssembly, fits curves around every area. Shapes are stacked on top of each other instead of cut out of each other, so no hairline gap can open between two colors.
  5. Handles soft shadows apart. In a transparent image, a drop shadow or glow is lifted out before step 2 and drawn as a few see-through layers under the artwork, so it stays soft.
  6. Writes the SVG with the palette's exact colors and the pixel size of the image you gave it.

Black & white mode skips steps 2 to 4 and uses a contour tracer of our own, which finds each outline straight from the brightness of the image. Centerline mode thins every line to its middle and fits one stroke to it. Both have their own pages: line art to SVG and centerline trace.

Flat art or painted: the engine picks one

After step 2 the engine checks how well a small set of flat colors explains the image. A logo fits almost perfectly. A watercolor, a photo or a gradient does not, because their colors change a little at every pixel. Those images take a different route: they are reduced to at most 24 tones and traced as bands, which is what a posterized print looks like.

SampleSourceColors foundSVGResult
Flat logo, 3 colors 512 px, 3.4 KB 3 3 paths, 2.1 KB Clean. The SVG is 1.3 KB smaller than the PNG.
Flat illustration, 5 colors 480 px, 28.7 KB 5 14 paths, 3.5 KB Clean. The SVG is 1/8 the size of the PNG.
Small icon, 4 colors 256 px, 1.9 KB 4 4 paths, 6.0 KB Clean, but small PNGs are already tiny. The SVG is 3 times the size of the PNG.
Watercolor illustration 480 px, 128.4 KB 24 (painted) 521 paths, 222.5 KB A posterized copy. The SVG is 2 times the size of the PNG.
Smooth gradients 420 px, 5.4 KB 24 (painted) 80 paths, 61.5 KB Bands of flat color. The SVG is 11 times the size of the PNG.

So the question to ask of an image is whether you could repaint it with a handful of flat colors. If yes, a trace will be clean. If its look depends on soft changes of tone, keep the PNG or JPG: the trace will be larger and look worse.

What each control changes

ControlRangeWhat it does
ColorsAuto, or 2 to 64Auto keeps the real colors it found, 24 at most. A number is a cap: the watercolor sample is 146 paths at 4 colors, 250 at 8, 394 at 16 and 521 on Auto.
Transparent backgroundOn or offDrops the color that runs around the border of the image, and its close shades. The logo sample on a white background goes from 4 paths to 3.
Despeckle0 to 40, default 8Merges areas smaller than this into their neighbors. Raise it for scanner dust and paper texture; lower it when small dots or thin strokes go missing.
Smoothing0.1 to 5, default 1Low keeps corners sharp and follows the pixels closely; high gives long, flowing curves with fewer points. The logo sample is 3.2 KB at 0.1, 2.1 KB at the default and 1.4 KB at 5.
ModeColor, B&W, Centerline, Cut fileWhich tracer runs. In B&W the logo sample is 2 black outlines, 2.4 KB. Cut file makes one layer for a cutting machine, on the Cricut page.

Most flat artwork needs none of them. Auto colors and the defaults produced every flat result on this page.

A real vector, or a picture wrapped in an SVG

An SVG file may hold a bitmap: an <image> tag with the original PNG inside it. A converter that writes such a file has traced nothing. The file blurs when enlarged exactly as the PNG did, and no editor or cutting machine can find a shape in it. There are three quick checks:

  • Zoom in. Edges of real paths stay sharp at any zoom. In our tool, the preview zooms and the divider compares it with your original.
  • Look at the paths. The Outlines button draws every path as a thin line, and the path count sits under the preview. A wrapped picture has no paths.
  • Open the file as text. A wrapped picture is one long data:image/png;base64, string.

What is in the file

This is the whole SVG our engine writes for the logo sample, with the curve data shortened:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Vectorized with vectorizely.com -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 1200" width="512" height="512">
<path d="M375,977c-.3-.3-.7-.7-1-1c-19.3-1-36.3-7.6-53.3-16.1…" fill="#2563EB"/>
<path d="M770,739c1.9,10.4,9.9,20.2,15.2,29.1c9.7,16.4,19.1,32.9…" fill="#F97316"/>
<path d="M377,841c1.4-9.5,6.4-14.8,10.9-23c12.1-21.8,25.8-42.3…" fill="#FFFFFF"/>
</svg>
  • viewBox is the coordinate grid the curves are drawn on, here the 1,200 px working size. width and height are the size of the image you loaded. Change those two and the drawing scales; the curves never change.
  • Each <path> is one color. Its d attribute is a list of moves (M) and curves (c), and fill is its color. Later paths are drawn over earlier ones.
  • No embedded image, no styles, no scripts. It is plain text, so it compresses well on a web server and reads cleanly in version control.

Using the SVG

  • On a web page. Use it as <img src="logo.svg">, or paste the markup into the page. Pasted markup can be styled: set a path's fill to currentColor and it takes the color of the text around it.
  • For people using screen readers. Give an inline SVG that carries meaning role="img" and an aria-label, or a <title> as its first child. Hide a decorative one with aria-hidden="true".
  • In a vector editor. Illustrator, Inkscape, Figma and Affinity Designer open it as separate shapes you can recolor, reshape or delete.
  • On a cutting machine or laser. Stacked shapes are wrong for cutting, because the blade would cut the hidden parts too. Use the cut file mode or the DXF export, which make shapes that do not overlap.
  • As a smaller file. SVGO rounds coordinates and strips what a renderer does not need. A trace is already a short file, so expect a modest saving.
  • Back to pixels. When a platform insists on a PNG, render the SVG at exactly the size it asks for.

Other ways to trace

  • Illustrator's Image Trace comes with an Adobe subscription and gives fine manual control. Our Image Trace page compares the two.
  • Inkscape's Trace Bitmap is free, runs on your computer and is built on Potrace, a black-and-white tracer it runs once per color.
  • Paid tracers that use machine learning are built for photographs and badly damaged sources, where a geometric tracer like ours is weakest.
  • Redrawing by hand is still the right answer for a logo that will be printed large, when the only source is small or blurred.

We ran Potrace, VTracer, ImageTracer.js, AutoTrace and our own engine on the same 20 images and published every number in the vectorizer benchmark.

Why it runs in your browser

All six steps above run on your own device, in a background thread of the page. The image is never sent to us, which matters for a client's logo or an unreleased design, and there is no upload to wait for. It is also why SVG, PNG and DXF downloads are free: a trace costs us nothing to run. PDF and EPS take a Pro pass.

Try it on your own image: PNG to SVG, JPG to SVG, any image to SVG, or vectorize a logo.

Frequently asked questions

Is tracing the same as converting a file format?

No. Converting PNG to JPG re-encodes the same grid of pixels. Tracing throws the grid away and draws new shapes that look like it, so the result is a reconstruction. For flat artwork the reconstruction matches the original closely; for a photo it cannot.

Why does the tracer find colors before it traces?

Because the edge of every shape in a PNG or JPG is a row of blended pixels, and a tracer that treats each blend as a color draws a thin extra shape along every edge. Finding the image's real colors first, then giving every pixel to one of them, removes those shapes before they exist. Our 5-color rocket sample traces to 14 paths this way.

How many paths should a good trace have?

About as many as the artwork has separate areas of color. The 3-color logo sample comes out as 3 paths and the 5-color rocket as 14. Hundreds of paths from a simple logo mean noise was traced as shapes; a painted or photographic image honestly needs hundreds (our watercolor sample takes 521).

Can a traced SVG be bigger than the image it came from?

Yes. Paths cost bytes per curve, pixels cost bytes per area. A small, simple PNG can already be tiny (our 256 px icon is 1.9 KB and its SVG is 6.0 KB), and a painted image needs so many paths that the SVG passes the PNG (222.5 KB against 128.4 KB). The SVG still scales to any size; the PNG does not.

Does tracing make text editable?

No. Letters come out as shapes that look like the letters. To get live text, retype it in a vector editor over the traced shapes, in the same or a similar font.