Converting PNG to SVG
Let’s say, you’ve found a funny black-and-white picture on the Internet and you want it badly in hi-res or vector which is even better. Well, there is a command-line tool called Potrace.
It has precompiled distributions for OS X, Linux and Windows. Potrace is also available in major package managers, including Homebrew:
The manual installation is super easy though. For OS X do the following:
Potrace works with bitmaps (PBM, PGM, PPM, or BMP format). It means you have to convert the image you have to one of those formats. We will be using ImageMagick’s
convert program. If you don’t have it installed, you can use Homebrew to get it:
Alright. Let's say you’ve got this image (by Nation of Amanda) in PNG format with transparency:
All you need to do is to run this:
It converts PNG file to PGM format, removes image transparency, outputs the result image to the standard input of
mkbitmap that transforms the input with highpass filtering and thresholding into a suitable for the
potrace program format, that finally generates SVG file. You can play around with highpass filtering (
-f) and thresholding (
-t) values until you have the final look that you want.
As a result you might have now: