Here are already such questions, like:

... and others.

I have an B&W png image, contains a drawing like an maze, e.g. it contains only lines, no areas.

Need convert it into (any) vector format, but as LINES. Every program what i tried, e.g. VectorMagic, potrace etc. converts the lines into closed path areas.

Small part of the original PNG image - zoomed: enter image description here

The result of the trace: enter image description here

As you can see, the "line" is traced from its both side like any other area-like shape.

Looking for a way, how to trace lines into real lines (PATHS), best with the matching line-width. (but would be enough any line with).

The reason behind: need work with the traced lines and nodes, e.g. convert some nodes to bezier and like. Not possible (easily) with shapes.

Any idea:

  • how to get vectorised lines from any tracing program.
  • which tool can do this? (any OS - could use Windows, OS X, Linux..)

7 Answers 7


Centerline Tracing

There is a free Open Source tool AutoTrace which is able to perform a centerline trace of a line-art bitmap.

enter image description here

Run AutoTrace with at least the following options:

autotrace -centerline -color-count 2 -output-file output.svg -output-format SVG input.png 

enter image description here

We can then fine tune the strokes and add the desired stroke strength..

We may also install the graphical frontend Frontline for AutoTrace in case we are not familiar with the command line.

Linux users may be able to install autotrace provided from their default repositories in most distributions. For Windows there are precompiled packages to download form the project's page.

There are many additional parameters for AutoTrace which can be found in the application's man page or by calling it with autotrace -help.

To rather get straight lines than splines we can e.g. use the following parameters:

  • -line-threshold [real]:
    If a spline does not deviate from the straight line defined by its endpoints by more than the specified number of pixels, then treat it as a straight line (default: 1).

  • - line-reversion-threshold [real]:
    If a spline is closer to a straight line than this, weighted by the square of the curve length, keep it a straight line even if it is a list with curves; default is .01.


In more recent versions (Inkscape 1.0+) centerline tracing using autotrace is included* in Inkscape via Path > Trace Bitmap:

enter image description here

* Reference: Inkscape 1.0 release notes

  • 1
    +1 Do you know if there is a option to tracer only make straight segments with autotrace.
    – joojaa
    Commented Sep 4, 2015 at 16:25
  • @joojaa: see edit for options.
    – Takkat
    Commented Sep 4, 2015 at 18:44
  • I wish I could get autotrace to build... I would love to use this Commented Jul 21, 2019 at 2:27
  • 1
    @slashdottir: what system are you using? The project's site moved to Github for recent deveIopment and for bug reports. I edited the answer to include the link.
    – Takkat
    Commented Jul 21, 2019 at 7:03
  • Oh brilliant! I'm using OSX. Thanks so much for the link! Commented Jul 21, 2019 at 13:54

Quite honestly... grab the pen tool and manually trace the paths. It'll result in the best output.

Auto-tracing is often not the best option. When you only want paths you can stroke, auto-trace generally fails miserably.

  • the image is really COMPLEX with many-many lines. Also have more images - simply too much work - looking for an alternative... ;)
    – clt60
    Commented Sep 4, 2015 at 13:40
  • also i hope than the "tool" will done some optimisation, e.g. will create always the longest possible paths and so on... manual work not always the best ;)
    – clt60
    Commented Sep 4, 2015 at 13:41
  • 1
    Good luck! I really think what you are asking for just takes manual skill and patience. I've never seen an automated solution that was worthwhile at creating single paths. I think your'e seeking the impossible honestly.
    – Scott
    Commented Sep 4, 2015 at 13:42
  • 2
    @scott while i in general agree with your sentiment in this specific case it just might work out.
    – joojaa
    Commented Sep 4, 2015 at 15:45

Try using Interpolate Paths after your trace, as show here:

Average stroke from a fill

  • WOW. This looks VERY promising. Thank you! +1.
    – clt60
    Commented Sep 4, 2015 at 13:44
  • @jm666 ofcourse rhis kind of method wont automate very well unless your dealing with continious paths.
    – joojaa
    Commented Sep 4, 2015 at 13:58

Illustrator can do center line tracing much like autotrace. Its not super useful for most things but in this case the image is highly synthetic and it might work.

Yor source image is notoriously bad so theres no real way to try this without losing quality, your originals should be better (no need to be so zoomed)

Do this:

  1. In trace settings disable fills and enable strokes.

  2. Object → Expand

enter image description here

Image 1: Object after trace and expand.

  1. To further enhance the results from any tracing errors do: Object → Path → Simplify, check straight edges.

enter image description here

Image 2: After simplification

  1. Seems to me your image is somewhat limitted in line directions, and corner locations, if thats true you could now try to quantitze the points for a even better (if not perfect) results.

enter image description here

Image 3: What quantizing might do to the result.

PS: given that the source that you shared is incomplete i would say my result as pretty good. While i agree that in general its not possible to rely on line tracing it would work in this case.

PPS: Your corners are overlapping, this causes auto tracers some grief You could detect and fix these with a few Morphology operators in say ImageMagick that should make tracers MUCH happier.

  • Also nice. Now using autotrace, because of the simple command line usage - for many images. The bitmap image above is a small part of an bigger image (1300% zoom) :) - therefore it looks degraded. +1, thank you.
    – clt60
    Commented Sep 4, 2015 at 15:36
  • @jm666 sure, you can aslo use illustrator from cmd if you wish, but its a bit of work to start.
    – joojaa
    Commented Sep 4, 2015 at 15:42
  • I tried with the Illustrator's image trace and the sample to use only strokes. I was unable to get any usable results. Admittedly I didn't invest a whole lot of time to it, and the sample isn't ideal for tracing. But I find in general setting AI's trace to only strokes means you only get 30-60% of the actual artwork traced unless the original is pretty solid and sharp before tracing.
    – Scott
    Commented Sep 4, 2015 at 19:41
  • @Scott i shrunk the image back to original(ish) size and adjusted line width parameter so that it just worked. When you trace strokes of different width you may need to do it in 2 or 3 separate passes.
    – joojaa
    Commented Sep 4, 2015 at 20:46

For Inkscape, there is also a centerline trace extension available on github: https://github.com/Moini/inkscape-centerline-trace (fork of https://github.com/fablabnbg/inkscape-centerline-trace)

  • 1
    Update: the fork's code has been merged to the original now, use the fablabnbg link.
    – Moini
    Commented Jan 8, 2019 at 22:14

I found a good freeware Tool called WinTopo, which for me did the job, i.e. centerline tracking.

The method is called "one touch vectorisation" and works well.

As I come from a GIS context - in the pro version there is an option to Georeference the raster data first - could be useful, not tested yet.


This is actually an answer to this question

Fitting vector curves/lines onto shapes in Illustrator

It's clearly closed by a single person who doesn't at all believe something useful can still be shown.

In the so called duplicates only the suggestion "trace it manually" is a good one. Unfortunately it's the same as draw a copy in Illustrator. It surely would be no problem for the maker of the original face drawing. He and his hands obviously know what he wants so well that he would draw a good copy on a graphics tablet in half a minute. But for others it needs well sharpened Bezier curve tool skills.

The next example shows how automatic middle-line stroke-only tracing fails in Illustrator:

enter image description here

In the left there's a raster image of a curve. In the right it's traced. In the crossings Illustrator couldn't guess the right path route and some unwanted twists are added.

You can make the tracing easier to Illustrator by erasing a little of the image in the crossings. Leave the most curved curve and erase pieces from the straighter branches so that there'a a well visible gap in both sides:

enter image description here

In the left the gaps are made in Photoshop.

In the middle there's the tracing result - expanded, ungrouped, the different sections are colored differently for clarity.

In the right the gaps are bridged. In this case I selected all and typed Ctrl+J to join the ends and nothing more.

If there's only a single open branch or three open branches coming towards the same crossing you must move one endpoint with the white arrow or extend the ends by drawing manually with the pen or line tool, because in Illustrator paths do not have three or more branch joints.

  • Questions aren't ever closed because "nothing helpful can be added". Questions are closed so that all, or most, of the information is unified to a single location. This allows future visitors to see as much information in a single question as possible. It's about data structure, not "nothing more can be added." You, correctly, added additional helpful information in a location that future visitors will actually see.. rather than requiring them to search/read multiple questions. (and users don't typically search beyond a first result.)
    – Scott
    Commented Mar 23, 2023 at 22:28
  • the interesting thing is that its pretty easy to filter for this automatically. So... that means there is no reason for the autotracer to be confused by this because it could be made to automatically handle the situation.
    – joojaa
    Commented Mar 24, 2023 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.