Learn how to digitize and vectorize a signature from a photo using the CLI tool Potrace.

How to digitize and vectorize signatures from a picture with Potrace CLI

Potrace is a CLI tool for tracing a bitmap, transforming a bitmap into a smooth, scalable image (SVG). The input needs to be a bitmap (PBM, PGM, PPM, or BMP format), and the output is one of several vector file formats. A typical use is to create SVG or PDF files from scanned data, such as company or university logos, handwritten notes, etc. The resulting image is not "jaggy" like a bitmap, but smooth. Then it can then be rendered at any resolution.

Potrace can currently produce the following output formats: SVG, PDF, EPS, PostScript, DXF, GeoJSON, PGM (for easy antialiasing of pixel-based images), Gimppath, and XFig. In this article, we'll show you how to use potrace to vectorize a signature from a camera photo with the CLI using a simple command.

1. Download Potrace

As first step, in case that you don't have potrace installed on your system (Windows or Unix based), you will need to acquire its binaries:

Source distribution: potrace-1.15.tar.gz
Precompiled distributions: Windows (64 bit) potrace-1.15.win64.zip
potrace-1.15.win64.tar.gz
Windows (32 bit) potrace-1.15.win32.zip
potrace-1.15.win32.tar.gz
Mac OS X (64 bit) potrace-1.15.mac-x86_64.tar.gz
Mac OS X (32 bit) potrace-1.15.mac-i386.tar.gz
Linux (64 bit) potrace-1.15.linux-x86_64.tar.gz
Linux (32 bit) potrace-1.15.linux-i386.tar.gz
Sun Solaris (Sparc) potrace-1.15.solaris-sparc.tar.gz
Sun Solaris (x86_64) potrace-1.15.solaris2.11-x86_64.tar.gz
Sun Solaris (i386) potrace-1.15.solaris2.11-i386.tar.gz
FreeBSD (x86_64) potrace-1.15.freebsd12-x86_64.tar.gz
NetBSD (x86_64) potrace-1.15.netbsd8-x86_64.tar.gz
OpenBSD (x86_64) potrace-1.15.openbsd61-x86_64.tar.gz
Minix (i386) potrace-1.15.minix-i386.tar.gz
Linux (Sparc) potrace-1.15.linux-sparc.tar.gz
Linux (Alpha) potrace-1.11.linux-alpha.tar.gz
AIX potrace-1.10.aix-rs6000.tar.gz
AROS (i386) potrace-1.9.aros-i386.zip
potrace-1.9.aros-i386.tar.gz
Packages: Solaris Package potrace-1.15.pkg.gz(1)
Redhat Source RPM potrace-1.15-1.src.rpm
Redhat Binary RPM (x86_64) potrace-1.15-1.x86_64.rpm
Amiga (OS4) potrace.lha (version 1.15)(5)
Package Management: Debian and Ubuntu apt-get install potrace(4)
SuSE potrace(6)
Fedora yum install potrace(7)
ArchLinux pacman -S potrace(8)
FreeBSD pkg_add -r potrace(9)
Fink (Mac OS X) fink install potrace(10)
Macports (Mac OS X) port install potrace(11)
NixOS nix-env -i potrace(12)

In environments like Ubuntu or CentOS is pretty easy to install with the command line and it will be immediately available from the command line as potrace. In Windows you will need to use the executable for the command with the full path:

"C:\\Program Files\\potrace\\potrace.exe" --svg signature.bmp -o signature.svg

Or make the path where potrace is extracted from the zip available from the path. For more information about potrace, don't forget to visit the official website here.

2. Convert your JPEG/PNG image to BMP

As next step, you only need an image of a signature from a photo, for example:

Random Signature

However, potrace needs an image in the Bitmap format. So be sure to convert your image to BMP using some tool like Imagick or an online tool.

3. Vectorize to SVG with Potrace

Finally, proceed to vectorize your BMP image with potrace with the following command:

REM Vectorize image with a simple command
potrace --svg signature.bmp -o signature.svg 

Note that with big images or when using directly from the CLI without automation (using potrace from a script in another programming language), you can display the progress of the vectorization adding the --progress option:

potrace --svg --progress signature.bmp -o signature.svg

Which outputs a simple progress bar:

Potrace from the CLI

Remember that Potrace works from BMP to SVG and other formats as PDF, however SVG is the standarized way to do it because you can use another tools as Imagick to convert it from SVG to PNG with transparency easily. For a detailed tutorial and description about all the options available of Potrace, don't forget to check the man page of potrace here.

The result of the previous command will be the output file, that in this case is signature.svg that contains our original image into a pretty nice vectorized result:

SVG Result Potrace

In this way with this tool, you will be able to save some dollars of cost when you pay to a graphic designer to digitize some client signature.

Happy coding !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors