[home]

Potrace

Transforming bitmaps into vector graphics


Contents

Description

Potrace(TM) is a tool for tracing a bitmap, which means, transforming a bitmap into a smooth, scalable image. The input is 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. 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. Additional backends might be added in the future.

Mkbitmap is a program distributed with Potrace which can be used to pre-process the input for better tracing behavior on greyscale and color images. See the mkbitmap examples page.

Example

Original image
Potrace output
More examples...

Mkbitmap examples...

Frequently asked questions

Trouble using Potrace? Here are the answers to some frequently asked questions.

News

For changes prior to version 1.14, see the file NEWS. For a more detailed list of changes, see the ChangeLog.

September 17, 2019: Release 1.16. This release consists of bugfixes and minor portability improvements. A potential arithmetic overflow was fixed. Rotation angles are now normalized to between -180 and 180. We now use binary file I/O on the OS/2 platform. The test suite tolerances were adjusted. The configuration option --enable-local-getopt was renamed as --with-included-getopt. Some build system improvements. Thanks to Henri Salo and Dave Yeo for reporting bugs and suggesting improvements.

August 5, 2017: Release 1.15. This release consists of bugfixes and minor portability improvements. Some potential buffer overflows and arithmetic overflows were fixed, including CVE-2017-12067. A bug triggered by very large bitmaps has been fixed. A new configuration option --enable-local-getopt was added. Thanks to Agostino Sarubbo, Daniel Macks, and Michael Voříšek for reporting bugs and suggesting improvements.

February 19, 2017: Release 1.14. This release consists of bugfixes and minor portability improvements. A number of bugs triggered by malformed BMP files have been fixed, including CVE-2016-8685 and CVE-2016-8686. Error reporting has been improved. The image size is now truncated when the bitmap data ends prematurely. It is now possible to use negative dy in bitmap data. Portability has been improved to encompass C++11. The default compiler is now clang if available. Thanks to Nelson Beebe and Martin Gieseking for reporting portability issues, and to Agostino Sarubbo for reporting bugs.

Downloading and installing

Potrace is built from sources using the standard configure/make commands. Please see the file INSTALL for generic installation instructions, and the file README for compile time configuration options specific to Potrace. Some pre-compiled binary distributions are also available. See the file README for instructions on how to install Potrace from a binary distribution. Additional instructions for Windows users are contained in the file README-WIN, or watch this video: Installing Potrace on Windows. If you would like to ensure the accuracy of the downloaded files, you can double-check their SHA1 sums.

Source distribution: potrace-1.16.tar.gz
Precompiled distributions: Windows (64 bit) potrace-1.16.win64.zip
potrace-1.16.win64.tar.gz
Windows (32 bit) potrace-1.16.win32.zip
potrace-1.16.win32.tar.gz
Mac OS X (64 bit) potrace-1.16.mac-x86_64.tar.gz
Linux (64 bit) potrace-1.16.linux-x86_64.tar.gz
Linux (32 bit) potrace-1.16.linux-i386.tar.gz
Sun Solaris (Sparc) potrace-1.15.solaris-sparc.tar.gz
Sun Solaris (x86_64) potrace-1.16.solaris2.11-x86_64.tar.gz(1)
Sun Solaris (i386) potrace-1.16.solaris2.11-i386.tar.gz(1)
FreeBSD (x86_64) potrace-1.15.freebsd12-x86_64.tar.gz(2)
NetBSD (x86_64) potrace-1.15.netbsd8-x86_64.tar.gz(2)
OpenBSD (x86_64) potrace-1.16.openbsd-x86_64.tar.gz
Minix (i386) potrace-1.16.minix-i386.tar.gz
Linux (Sparc) potrace-1.15.linux-sparc.tar.gz(2)
OS/2 potrace-1.16.os2.zip(3)
Linux (Alpha) potrace-1.11.linux-alpha.tar.gz(2)
AIX potrace-1.10.aix-rs6000.tar.gz
AROS (i386) potrace-1.9.aros-i386.zip
potrace-1.9.aros-i386.tar.gz(4)
Packages: Windows installer (64 bit) Potrace-1.11-64-bit-setup.msi(5)
Windows installer (32 bit) Potrace-1.11-32-bit-setup.msi(5)
Solaris Package potrace-1.15.pkg.gz(1)
Redhat Source RPM potrace-1.16-1.src.rpm
Redhat Binary RPM (x86_64) potrace-1.16-1.x86_64.rpm
Amiga (OS4) potrace.lha (version 1.16)(6)
Package Management: Debian and Ubuntu apt install potrace(7)
SuSE potrace(8)
Fedora dnf install potrace(9)
ArchLinux pacman -S potrace(10)
FreeBSD pkg_add -r potrace(11)
Fink (Mac OS X) fink install potrace(12)
Macports (Mac OS X) port install potrace(13)
NixOS nix-env -i potrace(14)
(1) Solaris-i386 and x86_64 binaries and packages provided by Apostolos Syropoulos <asyropoulos at gmail.com>.
(2) Linux for Alpha and Sparc, FreeBSD, and NetBSD binaries provided by Nelson Beebe <beebe@math.utah.edu>.
(3) OS/2 binaries provided by Dave Yeo <dave.r.yeo@gmail.com>. See also the Hobbes OS/2 Archive.
(4) AROS binaries supplied by Matthias Rustler <mrustler at gmx.de>. See the AROS archives for sources and updates.
(5) Windows installers provided by G. Adam Stanislav <adam@redprince.net&bt;.
(6) Amiga Package provided by Guillaume Boesel <guillaume at boesel.fr>. See the OS4 Depot for updates.
(7) Debian i386 Package maintained by Bartosz Fenski <fenio at debian.org>. Debian has centralized package management and users should run "sudo apt install potrace" to install.
(8) SuSE RPMs provided by Stanislav Brabec <sbrabec at suse.cz>. Potrace appears in the official SuSE distribution.
(9) Fedora package maintained by Susi Lehtola <potrace-owner@fedoraproject.org>. Potrace is available on all Fedora branches. Fedora has centralized package management and users should run "dnf install potrace" as root to install.
(10) ArchLinux package maintained by Damir Perisa <damir at archlinux.org>. ArchLinux has centralized package management and users should run "pacman -S potrace" as root to install.
(11) FreeBSD Packages maintained by Piotr Smyrak <piotr at smyrak.com>.
(12) Fink package maintained by Daniel Macks <dmacks at netspace.org>. Fink has centralized package management and users should run "fink install potrace" as root to install.
(13) Macports has centralized package management and users should run "port install potrace" as root to install.
(14) NixOS has centralized package management and users should run "nix-env -i potrace" as root to install.

Previous releases...

Usage

potrace 1.16. Transforms bitmaps into vector graphics.

Usage: potrace [options] [filename...]
General options:
 -h, --help                 - print this help message and exit
 -v, --version              - print version info and exit
 -l, --license              - print license info and exit
File selection:
 filename                   - an input file
 -o, --output filename      - write all output to this file
 --                         - end of options; 0 or more input filenames follow
Backend selection:
 -b, --backend name         - select backend by name
 -b svg, -s, --svg          - SVG backend (scalable vector graphics)
 -b pdf                     - PDF backend (portable document format)
 -b pdfpage                 - fixed page-size PDF backend
 -b eps, -e, --eps          - EPS backend (encapsulated PostScript) (default)
 -b ps, -p, --postscript    - PostScript backend
 -b pgm, -g, --pgm          - PGM backend (portable greymap)
 -b dxf                     - DXF backend (drawing interchange format)
 -b geojson                 - GeoJSON backend
 -b gimppath                - Gimppath backend (GNU Gimp)
 -b xfig                    - XFig backend
Algorithm options:
 -z, --turnpolicy policy    - how to resolve ambiguities in path decomposition
 -t, --turdsize n           - suppress speckles of up to this size (default 2)
 -a, --alphamax n           - corner threshold parameter (default 1)
 -n, --longcurve            - turn off curve optimization
 -O, --opttolerance n       - curve optimization tolerance (default 0.2)
 -u, --unit n               - quantize output to 1/unit pixels (default 10)
 -d, --debug n              - produce debugging output of type n (n=1,2,3)
Scaling and placement options:
 -P, --pagesize format      - page size (default is letter)
 -W, --width dim            - width of output image
 -H, --height dim           - height of output image
 -r, --resolution n[xn]     - resolution (in dpi) (dimension-based backends)
 -x, --scale n[xn]          - scaling factor (pixel-based backends)
 -S, --stretch n            - yresolution/xresolution
 -A, --rotate angle         - rotate counterclockwise by angle
 -M, --margin dim           - margin
 -L, --leftmargin dim       - left margin
 -R, --rightmargin dim      - right margin
 -T, --topmargin dim        - top margin
 -B, --bottommargin dim     - bottom margin
 --tight                    - remove whitespace around the input image
Color options, supported by some backends:
 -C, --color #rrggbb        - set foreground color (default black)
 --fillcolor #rrggbb        - set fill color (default transparent)
 --opaque                   - make white shapes opaque
SVG options:
 --group                    - group related paths together
 --flat                     - whole image as a single path
Postscript/EPS/PDF options:
 -c, --cleartext            - do not compress the output
 -2, --level2               - use postscript level 2 compression (default)
 -3, --level3               - use postscript level 3 compression
 -q, --longcoding           - do not optimize for file size
PGM options:
 -G, --gamma n              - gamma value for anti-aliasing (default 2.2)
Frontend options:
 -k, --blacklevel n         - black/white cutoff in input file (default 0.5)
 -i, --invert               - invert bitmap
Progress bar options:
 --progress                 - show progress bar
 --tty mode                 - progress bar rendering: vt100 or dumb

Dimensions can have optional units, e.g. 6.5in, 15cm, 100pt.
Default is inches (or pixels for pgm, dxf, and gimppath backends).
Possible input file formats are: pnm (pbm, pgm, ppm), bmp.
Backends are: svg, pdf, pdfpage, eps, postscript, ps, dxf, geojson, pgm, 
gimppath, xfig.

For detailed usage information, see the potrace(1) man page.

Technical documentation

  • For detailed usage information, see the man pages of potrace(1) and mkbitmap(1).
  • A detailed technical description of how the Potrace algorithm works [pdf].
  • Technical documentation of the Potrace library API (for developers) [pdf].

Support and reporting bugs

Get Potrace at
 SourceForge.net. Fast, secure and Free Open Source software
 downloads Potrace has a project page on SourceForge. There, you will find facilities for reporting bugs, submitting patches, asking for support, asking for features, or discussing Potrace in general. You are encouraged to use these facilities. You can also send email to the author. Please also check the Frequently Asked Questions.

Dual licensing program

Icosasoft
 Logo A non-GPL version of Potrace, called Potrace Professional(TM), is available for integration into proprietary software. Licenses are available from my company, Icosasoft Software Inc. If you wish to purchase a license, or for more information, please write to licensing@icosasoft.ca.

Related software and services

Commercial software:
  • Image Vectorizer, by Icosasoft Software Inc. An easy-to-use image vectorizer for Mac OS X. (Added January 26, 2014).

  • Type 3.2 Font Editor, by CR8 Software Solutions. A font editor that's easy to use for Windows and Mac. (Added May 11, 2015).

  • Lazeroy, by Günili Yazılım. An application for creating halftoned CMYK images and DXF files from color images. (Added June 3, 2019).
Graphical user interfaces:
  • Potrace GUI, by Rasmus Andersson. A GUI for Potrace for Mac OS X. The source code is here. (Added Sept 22, 2003).

  • potracegui, by Antonio Fasolato. A GUI for Potrace using KDE. (Added Nov 29, 2003).

  • delineate, by Robert McKinnon. A GUI for Potrace and Autotrace using Java. There are versions for Mac OS X, GNU/Linux, and Windows. (Added Feb 11, 2003).

  • Rasterbater 1.0, by Kevin Cole. A GUI for Potrace using C#. (Added December 20, 2007).

  • CR8tracer, by Allan Murray. A Windows GUI for Potrace. (Added December 20, 2007).

  • DragPotrace, by Akira Sato. A Mac OS X GUI for Potrace. (English). (Added October 14, 2011).
Web interfaces:
  • Vectorization.org, by Tobias Reinhardt. An easy-to-use web interface to Potrace. (Added January 26, 2014).

  • SVGcode, by Thomas Steiner. A web interface to Potrace that can also do color tracing. [source]. (Added November 19, 2021).
Software that uses Potrace:
  • FontForge, by George Williams. An outline font editor that lets you create and edit postscript and truetype fonts, among others. This program can invoke Autotrace or Potrace for converting bitmaps to vector fonts. It used to be called "PfaEdit". (Added Aug 21, 2003).

  • mftrace, by Han-Wen Nienhuys. A small Python program that lets you trace a TeX bitmap font into a PFA or PFB font (A PostScript Type1 Scalable Font) or TTF (TrueType) font (Added Dec 13, 2003).

  • LilyPond, by Han-Wen Nienhuys and Jan Nieuwenhuizen. An application that let you typeset beautiful sheet music. It uses Potrace indirectly via mftrace. (Added Apr 22, 2004).

  • TeXtrace, by Péter Szabó. A collection of scripts that convert any TeX font into a Type1 .pfb outline font. The newest version (0.50) supports Potrace via the --potrace option. (Added Apr 22, 2004).

  • Inkscape, by various authors. This is an excellent SVG editor. Potrace has been integrated since release 0.40. (Added Sep 16, 2004).

  • dvisvgm, by Martin Gieseking. This is a tool for converting DVI files, as generated by TeX/LaTeX, to the XML-based Scalable Vector Graphics format. (Added Aug 24, 2005).

  • pocopo, by Paul Yoon. An AppleScript for processing color images, using Potrace. (Added Oct 28, 2005).

  • BMP 2 EPS, by Maddis. A Potrace front end for BluffTitler users. (Added Jun 21, 2009). See also here.

  • PCB, by Thomas Nau, Harry Eaton, and others. An interactive editor for printed circuit boards. (Added Jul 1, 2014).

  • JJMack's Potrace Script, by John J. McAssey. A Photoshop script for creating custom shapes. (Added Dec 1, 2014).

  • Stencilcreator.org, by A. Jain, C. Chen, T. Thormählen, D. Metaxas and H.-P. Seidel. A website where you can create a set of stencils from an image. A stencil is a cut-out template that can be used to paint with color onto a surface. (Added Nov 6, 2015).

  • Stencil-o-Matic and Stamp-o-Matic, by Benjamin. Make stencils or stamps from pictures of your choice. (Added Mar 28, 2020).

  • PDFsak, by Raffaele Mancuso. A "Swiss army knife" for manipulating PDF files, such as merging, n-upping, trimming, rotating, etc. (Added Dec 7, 2021).
Software and services that are similar to Potrace:
  • Autotrace, by Martin Weber. This program performs a similar task as Potrace. In my opinion, the output is not as nice, but it supports a much larger number of file formats, and it has been integrated with a larger number of other software packages. (Added Nov 29, 2003).
  • Vector Magic. A commercial tracing tool that is available through a web interface, for a fee. Unlike Potrace, Vector Magic works for color images.
  • Vectorize Now. A commercial vectorizing service where each image is redrawn by hand. Black-and-white or color. (Added Oct 31, 2015).
Non tracing-based image enhancement software:
  • GREYCstoration, by David Tschumperlé. If the examples on the webpage are representative, then this is the most astonishingly good image regularization filter that I have ever seen. It is based on a non-linear diffusion technique. It can be used for noise and artifact removal, resizing, and inpainting (which means filling in missing image regions). It works on color photographs and cartoons. (Added Feb 2, 2006).

Projects using Potrace

Here are some projects by people who have used Potrace to do interesting things. I particularly love projects that use Potrace to create objects in the physical world, such as C. Scott Ananian's article on how to make stained glass windows from color scans, and Matt Parsons's project on creating a model airplane from old scanned blueprints.

Articles about Potrace

Here are some web articles, listings, blogs, and books that cover Potrace and its applications.

Ports to other programming languages

Important notice about ports. If you are planning to modify Potrace, including making a port of Potrace to another programming language, please be aware of the following. While the source code of Potrace is licensed under the GNU General Public License, the name "Potrace" is my trademark, and may only be used with my permission.

In practice, I will permit the use of the name "Potrace" in connection with a port of Potrace to another programming language, provided that the port complies with the term of the GNU General Public License and produces the same high quality vectorized output as the original Potrace. Ports that are buggy or do not produce high quality output are not permitted to use the name "Potrace". To ensure compliance with this policy, please run your port by me before making it public. Also, if you use the "Potrace" name (or any derivative, such as "MyPotrace"), you must provide a name and email address where I can reach you. Derivatives of Potrace that are posted anonymously or where the authors cannot be reached or do not reply to email or bug reports are not permitted to use the name "Potrace".

Notwithstanding the foregoing paragraph, I do not warrant the quality of any third-part ports; any ports that are posted here are provided "as is", without any warranty.

  • Potracer, by Kenny Parnell. Ruby bindings for Potrace. (Added October 16, 2012).
  • as3potrace, by Claus Wahlers. A port of Potrace 1.8 to ActionScript 3.0 (Flash). (Added May 1, 2011).
  • PotrAs, by Nitoyon. Another port of Potrace 1.8 to ActionScript 3.0 (Flash). (Added May 1, 2011).
  • Vectorization, by Wolfgang Nagl. A port of Potrace 1.8 to C# Visual Studio. (Added Aug 23, 2009, updated Feb 23, 2016).
  • PyPotrace, by Eternalsquire. Python bindings for Potrace. (Added Apr 12, 2010).
  • pypotrace, by Luper Rouch. Python bindings for Potrace, also available here. (Added Apr 12, 2010).
  • Graphics::Potrace, by Flavio Poletti. Perl bindings for Potrace, also available here. (Added Dec 26, 2013).
  • A JavaScript port of Potrace, by Kilobtye. (Added Mar 20, 2017).
  • Swift Potrace, by Paul Colton. A port of Potrace to the Swift language. (Added May 22, 2017).
  • A PHP port of Potrace, by Otamay. (Added Jul 7, 2018).
  • A Dart port of Potrace, by Justin Foutts. (Added Apr 18, 2019).
  • ESM Potrace Wasm, by Thomas Steiner. An ESM WebAssembly port of Potrace. (Added Nov 22, 2021).

Version

1.16

Author

Copyright © 2001-2019 Peter Selinger.

Logo

The Potrace logo and mascot was designed by Karol Krenski. Copyright © 2003 Karol Krenski and Peter Selinger. The logo is licensed under GPL.

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

Trademarks

"Potrace" is a trademark of Peter Selinger. "Potrace Professional" and "Icosasoft" are trademarks of Icosasoft Software Inc. Other trademarks belong to their respective owners.

To my other software.
Peter Selinger / Department of Mathematics and Statistics / Dalhousie University
selinger@users.sourceforge.net / PGP key