How to correctly using potrace (CLI) to trace bitmap
I was trying to vectorize a
.png. I found a utility (which is incorporated into InkScape), the
potrace. If any of you knows how to use
potrace, kindly teach me the right way to get sharp output.
Consider this input (png).
potrace, the picture must be in bitmap format. So I converted it by using imagemagick.
convert image.png image.bmp
Then I proceeded with
potrace --svg falcon.bmp -o falcon.svg
But unfortunately, the output looks obviously dull.
I don't really understand the options (
potrace -h). Or if there's a better alternative other than
potrace, just tell me.
Tracing with BirdFont
The potrace algorithm is good but no autotrace algorithm is perfect.
I had a similar problem when I tried to auto trace letters with potrace. Small details are not preserved and the result seems to be a little bit smoother than I wanted it to be. I solved this by implementing my own autotrace functionality in BirdFont. It seems to work a little bit better but it is not as fast as the potrace algorithm.
The image looks like this when converted to black and white:
And the traced result looks like this:
This image was generated with the following settings:
- Cubic BeziÃ©r paths
- Contrast: 0.59
- Amount of details: 3.0
- Simplification: 0.1
BirdFont is a font editor and TTF is the most common font format fonts but you can export the generated image as SVG.
Edit->Export Glyph as SVG
You can find more instructions on the autotrace functionality at the BirdFont website.
I recommend you to download the GUI interface for potrace and autotrace, which contains two algorithms for tracing bitmapped images. It collects informations in an easy way (hopefully) and then it launches potrace or autotrace with all the relevant options. Using a GUI sometimes is more comfortable that using command line, it is more interactive, and it will easy for you to try different the settings.
How can I improve the quality of the output of Potrace?
The most effective way to do so is to improve the quality of the input!. Scan your image at a higher resolution. Scan your image in greyscale, and use a program such as mkbitmap to generate a high-resolution bitmap to trace.
In some cases, it also helps to decrease the resolution of the input image. If the resolution of your input file is incredibly high, the output generated by Potrace might be larger than necessary. This also sometimes happens if the input is speckly or noisy. Rather than trying to simplify the vector image, it often helps to just downscale the input bitmap.
There is an utility called
mkbitmap which converts color or greyscale images into a format suitable as input for other programs, particularly the tracing program
Potrace. It is particularly useful for converting scanned line art, such as cartoons, handwritten text, etc., to high-resolution bilevel images.
In this website you can find some examples of the operation of mkbitmap.