potrace(1)
π potrace(1) β General Commands Manual π
okay bestie, buckle up, because this is the manual page for potrace and it's lowkey iconic. π
β¨ NAME β¨
potrace β transform bitmaps into vector graphics. fr fr, that's the whole vibe. π¦
β¨ SYNOPSIS β¨
potrace [options] [filename...]
β¨ DESCRIPTION β¨
so potrace is this tool for tracing a bitmap, which means turning a bitmap into a smooth, scalable image. π«Ά The input is a bitmap, which means a pixel-based image made of literally just two colors: black and white. The output is SVG, PDF, EPS, or one of a number of other vector formats. A typical use is making vector graphics out of scanned data β think company logos, university logos, handwritten notes, that kind of thing. π The resulting image is not "jaggy" like a bitmap, it's smooth. And then it can be rendered at any resolution. slay.
potrace can read bitmaps in the following formats: PBM, PGM, PPM (collectively known as PNM, see pnm(5)), plus BMP (Windows and OS/2 bitmap formats). The input image should only use the two colors black and white. If other pixel values show up in the input, they get converted to black and white using a simple threshold method.
potrace can currently produce the following output formats: SVG, PDF, EPS, PostScript, DXF, GeoJSON, PGM, Gimppath, and XFig. Additional backends might be added in the future. π
β¨ OPTIONS β¨
The following options are supported. Dimensions (arguments of type dim) can have optional units, e.g. 6.5in, 15cm, 100pt. The default unit is inches (or centimeters, if this was configured at compile time, see COMPILE TIME CONFIGURATION below). For pixel-based output formats such as PGM, DXF, GeoJSON, and Gimppath, the default unit is pixels.
π General options:
-h,--helpβ print help message and exit.-v,--versionβ print version info and exit. This also shows the defaults that were compiled into this version ofpotrace. π-l,--licenseβ print license info and exit.
π Input/output options:
filenameβ Each file can hold an input image, or multiple concatenated input images. If filename arguments are given, thenpotracewill by default create one output file for each input filename given. The name of the output file is obtained from the input filename by changing its suffix according to the chosen backend. If changing the suffix is impossible because the names of the input and output files would be identical, then the output filename is created by adding the"-out"suffix to the name of the input file. If no filename arguments are given, thenpotraceacts as a filter, reading from standard input and writing to standard output. A filename of"-"may be given to specify reading from standard input.-ofilename,--outputfilename β write output to this file. All output is directed to the specified file. If this option is used, then multiple input filenames are only allowed for multi-page backends (seeBACKEND TYPESbelow). In this case, each input file may contain one or more bitmaps, and all the bitmaps from all the input files are processed and the output concatenated into a single file. A filename of"-"may be given to specify writing to standard output.--β End of options. Any remaining arguments are interpreted as filenames. This also disables filter mode, even if no filenames are given. This is useful for shell scripts, becausepotrace -- $FILENAMESwill behave correctly even for an empty list of filenames.
π¨ BUT. However,--with an empty list of filenames is not permitted in conjunction with the-ooption, because this would generate a document of zero pages, which none of the backends permit. not me finding the one edge case π
π Backend selection:
For general information, see also BACKEND TYPES below.
-bname,--backendname β Select backend by name, where name is one ofeps,postscript,ps,pdf,pdfpage,svg,dxf,geojson,pgm,gimppath,xfig. Backend names can be abbreviated by a prefix as long as it is unambiguous. Backend names are case insensitive.-s,--svg,-b svg,--backend svgβ SVG backend. The output is a Scalable Vector Graphics (SVG) file. This is a single-page, variable-sized, dimension-based backend. Note that unless the-roption is given, the resolution of the input bitmap is assumed to be72dpi. π-b pdf,--backend pdfβ PDF backend. The output is a file in the Portable Document Format. If the input consists of multiple bitmaps, they are each rendered on a separate page. This is a multi-page, variable-sized, dimension-based backend.-b pdfpage,--backend pdfpageβ ThePDFPagebackend is like the PDF backend, except that it is fixed-size like the PostScript backend.-e,--eps,-b eps,--backend epsβ EPS backend (default). The output is an encapsulated PostScript file. This is a single-page, variable-sized, dimension-based backend. π-p,--postscript,-b ps,--backend psβ PostScript backend. The output is a PostScript file. This is a multi-page, fixed-size, dimension-based backend. If the input consists of multiple bitmaps, they are each rendered on a separate page.-b dxf,--backend dxfβ DXF backend. The output is a file in the Drawing Interchange Format (DXF). In this backend, all Bezier curves are approximated by piecewise circular arcs; this is suitable for processing in CAD software or for machining applications using CNC tools. This is a single-page, variable-sized, pixel-based backend. The-uoption has no effect for this backend.-b geojson,--backend geojsonβ GeoJSON backend. The output is a file in the format used by some applications processing geographical data. In this backend, all Bezier curves are approximated by8straight line segments. This is a single-page, variable-sized, pixel-based backend. The-uoption has no effect for this backend.-g,--pgm,-b pgm,--backend pgmβ PGM backend. The output is a portable greymap (PGM) file. It is a convenient backend for antialiasing a bitmap image. This is a multi-page, variable-sized, pixel-based backend. If the input consists of more than one image, the images are concatenated in the output.-b gimppath,--backend gimppathβ Gimppath backend. This backend produces output suitable to be imported as a path by the GNU Image Manipulation Program (Gimp) (in the Layers, Channels & Paths dialog, select Paths, then right-click and select Import Path). The output is actually anSVGfile. The differences to the SVG backend are: the--opaqueoption has no effect, the--flatoption is always on, and the dimensions are pixel-based. This is a single-page, variable-sized, pixel-based backend. π¨-b xfig,--backend xfigβ XFig backend. This is a single-page, fixed-size, dimension-based backend. The output is a file in the XFig format. Note that XFig uses X-splines instead of Bezier curves, thus it is not possible to translate the output ofpotraceinto the XFig format with absolute accuracy. π This backend does a reasonable approximation using two control points for each Bezier curve segment. The-uoption has no effect for this backend, because control points are always rounded to the nearest1/1200of an inch in XFig. Curve optimization is disabled. Implies--opaque.
π Algorithm options:
For more detailed information on these options, see TECHNICAL DOCUMENTATION below. π§
-zpolicy,--turnpolicypolicy β specify how to resolve ambiguities in path decomposition. Must be one ofblack,white,right,left,minority,majority, orrandom. Default isminority. Turn policies can be abbreviated by an unambiguous prefix, e.g., one can specifymininstead ofminority.-tn,--turdsizen β suppress speckles of up to this many pixels. π§Ή-an,--alphamaxn β set the corner threshold parameter. The default value is1. The smaller this value, the more sharp corners will be produced. If this parameter is0, then no smoothing will be performed and the output is a polygon. If this parameter is greater than4/3, then all corners are suppressed and the output is completely smooth.-n,--longcurveβ turn off curve optimization. Normallypotracetries to join adjacent Bezier curve segments when this is possible. This option disables this behavior, resulting in a larger file size.-On,--opttolerancen β set the curve optimization tolerance. The default value is0.2. Larger values allow more consecutive Bezier curve segments to be joined together in a single segment, at the expense of accuracy.-un,--unitn β set output quantization. Coordinates in the output are rounded to1/unitpixels. The default of10usually gives good results. For some of the debug modes, a value of100gives more accurate output. This option has no effect for the XFig backend, which always rasterizes to1/1200inch, or for the DXF backend. For the GeoJSON backend, this option is only a hint; the actual rounding may be more, but not less, accurate than specified.-dn,--debugn β produce debugging output of type n. This has different effects for different backends. For the PostScript/EPS backends, the valuesn=1,2,3illustrate the intermediate stages of thepotracealgorithm. π
more coming bestie, don't go anywhere π«Ά
πΈ Scaling and placement options πΈ
Okay bestie, this is the glow-up section. Everything about how big your output is and where it sits. β¨
-P format,--pagesize formatβ for fixed-size backends, this sets the page size. The formats you can pick are:A4,A3,A5,B5,Letter,Legal,Tabloid,Statement,Executive,Folio,Quarto,10x14. Format names are case insensitive, so type them however you vibe. You can also pass an argument of the formdimxdimto specify arbitrary dimensions, iconic. The default page size isLetter(orA4, if this was configured at compile time β see COMPILE TIME CONFIGURATION below). Page format names can be abbreviated by a prefix as long as it is unambiguous. This option has no effect for variable-sized backends, so don't come for it.-W dim,--width dimβ set the width of the output image (before any rotation and margins). If only one of width and height is specified, the other is adjusted accordingly so that the aspect ratio is preserved. Considerate king behavior. π-H dim,--height dimβ set the height of the output image. See-Wfor details, it's the same energy.-r n[xn],--resolution n[xn]β for dimension-based backends, set the resolution (in dpi). One inch in the output image corresponds to this many pixels in the input. Note that a larger value results in a smaller output image (yes really, it's giving backwards but it's not). You can specify separate resolutions in the x and y directions by giving an argument of the formnxn. For variable-sized backends, the default resolution is72dpi. For fixed-size backends, there is no default resolution; the image is by default scaled to fit on the page. This option has no effect for pixel-based backends. If-Wor-Hare specified, they take precedence.-x n[xn],--scale n[xn]β for pixel-based backends, set the scaling factor. A value greater than1enlarges the output, a value between0and1makes the output smaller. The default is1. You can also specify separate scaling factors for the x and y directions by giving an argument of the formnxn. This option has no effect for dimension-based backends. If-Wor-Hare specified, they take precedence.-S n,--stretch nβ set the aspect ratio. A value greater than1means the image will be stretched in the y direction. A value between0and1means the image will be compressed in the y direction. Squish era. π«-A angle,--rotate angleβ set the rotation angle (in degrees). The output will be rotated counterclockwise by this angle. This is useful for compensating for images that were scanned not quite upright β we've all been a little crooked, no judgment. π-M dim,--margin dimβ set all four margins. The effect and default value of this option depend on the backend. For variable-sized backends, the margins will simply be added around the output image (or subtracted, in case of negative margins). The default margin for these backends is0. For fixed-size backends, the margin settings can be used to control the placement of the image on the page. If only one of the left and right margin is given, the image will be placed this distance from the respective edge of the page, and similarly for top and bottom. If margins are given on opposite sides, the image is scaled to fit between these margins, unless the scaling is already determined explicitly by one or more of the-W,-H,-r, or-xoptions. By default, fixed-size backends use a non-zero margin whose width depends on the page size.-L dim,--leftmargin dimβ set the left margin. See-Mfor details.-R dim,--rightmargin dimβ set the right margin. See-Mfor details.-T dim,--topmargin dimβ set the top margin. See-Mfor details.-B dim,--bottommargin dimβ set the bottom margin. See-Mfor details.--tightβ remove whitespace around the image before scaling and margins are applied. If this option is given, calculations of the width, height, and margins are based on the actual vector outline, rather than on the outer dimensions of the input pixmap, which is the default. In particular, the--tightoption can be used to remove any existing margins from the input image. See the fileplacement.pdffor a more detailed illustration. π
π Color options π
These options are only supported by certain backends. The DXF and GeoJSON backends do not support color. Not every backend woke up and chose color, and that's their journey.
-C #rrggbb,--color #rrggbbβ set the foreground color of the output image. The default is black. π€--fillcolor #rrggbbβ set the fill color of the output image, i.e., the color of the "white" parts that are enclosed by "black" parts. The default is to leave these parts transparent. Implies--opaque. Please note that this option sets the background color; to set the foreground color, use--colorinstead. Yes bestie this trips everyone up, read it twice. π--opaqueβ fill in the white parts of the image opaquely, instead of leaving them transparent. This only applies to interior white parts, i.e., those that are enclosed inside a black outline. Opaqueness is always in effect for the XFig backend, it simply refuses to be see-through.
π¦ SVG options π¦
--groupβ for SVG output, try to group related paths together. Each path is grouped together with all paths that are contained inside it, so that they can be moved around as a unit with an SVG editor. This makes coloring individual components slightly more cumbersome, and thus it is not the default. Convenient for moving, annoying for coloring β pick your fighter. β¨--flatβ for SVG output, put the entire image into a single path. This makes it impossible to color the components individually, and thus it is not the default. But the resulting SVG file can be more easily imported by some applications such as Gimp. In fact, the Gimppath backend is a variation of the SVG backend with the--flatoption and pixel-based scaling. The--flatoption has no effect if--opaquehas been selected. Not them cancelling each other out π
β PostScript/EPS/PDF options β
-c,--cleartextβ do not compress the output. This option disables the use of compression filters in the PostScript and PDF output. In the PostScript backend, if-cand-qare used together, the resulting output can be easily read by other programs or even by humans. Human-readable output, we love a transparency moment.-2,--level2β use PostScript level 2 compression (default). The resulting file size is ca.40%smaller than if the-coption is used. The classic, the reliable, the default.-3,--level3β use PostScript level 3 compression, if available. This gives slightly smaller files than using-2, but the resulting files may not print on older PostScript level 2 printers. If support for PostScript level 3 compression has been disabled at compile time, a warning message is printed and level 2 compression is used instead. Shiny new tech but your grandma's printer said no. π¨οΈ-q,--longcodingβ turn off optimized numerical coding in PostScript output. Normally,potraceuses a very compact numerical format to represent Bezier curves in PostScript, taking advantage of existing redundancy in the curve parameters. This option disables this behavior, resulting in longer, but more readable output (particularly if the-coption is also used). Longer but legible, the trade-off of the century.
π PGM options π
-G n,--gamma nβ set the gamma value for anti-aliasing (default is2.2). Most computer displays do not render shades of grey linearly, i.e., a grey value of0.5is not displayed as being exactly half-way between black and white. The gamma parameter corrects for this, and therefore leads to nicer looking output. The default value of2.2is appropriate for most normal CRT displays. Fixing the display's little lies, one grey at a time. β¨
π Frontend options π
-k n,--blacklevel nβ set the threshold level for converting input images to bitmaps. Thepotracealgorithm expects a bitmap, thus all pixels of the input images are converted to black or white before processing begins. Pixels whose brightness is less thannare converted to black, all other pixels to white. Herenis a number between0and1. One case is treated specially: if the input is in an indexed color format with exactly 2 colors, then the blacklevel is ignored and the darker of the two colors is mapped to black. Special little exception, love that for it. π
Note: the method used bypotracefor converting greymaps to bitmaps is very crude; much better results can be obtained if a separate program, such asmkbitmap(1), is used for this purpose. In particular,mkbitmap(1), which is distributed withpotrace, has the ability to scale and interpolate the image before thresholding, which results in much better preservation of detail. So like, it works, but the glow-up is one command away bestie. π
-i,--invertβ invert the input bitmap before processing. Flip it, reverse it, the negative era. π
π Progress bar options π
--progressβ display a progress bar for each bitmap that is processed. This is useful for interactive use. The default behavior is not to show any progress information. We love a little "loadingβ¦" moment, it's giving main character energy. π--tty modeβ set the terminal mode for progress bar rendering. Possible values are"vt100", which requires a vt100-compatible terminal, and"dumb", which uses only ASCII characters. The default is system dependent. Pick your aesthetic, we support both. π
π BACKEND TYPES π
ok so backends? they come in flavors, and the flavor decides which command line options you even get and how they act. three whole vibe axes, bestie:
π Fixed-size or variable-sized
For fixed-size backends, the size of the page is always the same β like Letter or A4, as specified at compile time or by the -P option. By default, the image will be centered and scaled to fit the page size. For variable-size backends, the size of the page follows the size of the image. Currently the PostScript (PS), PDFPage, and XFig backends are fixed-size, and the remaining backends are variable-size.
π¦ Dimension-based or pixel-based
In dimension-based backends, distances are measured in physical units such as inches or centimeters. In pixel-based backends, distances are measured in pixel units. The -r option only works for dimension-based backends, and the -x option only works for pixel-based backends. Currently, the DXF, PGM, Gimppath, and GeoJSON backends are pixel-based, and the remaining backends are dimension-based. Currently, all pixel-based backends are variable-sized.
β¨ Single-page or multi-page
Single-page backends can only accept a single image. Multi-page backends can accept multiple images, typically one per page of output. Currently, the PostScript (PS), PDF, PDFPage, and PGM backends are multi-page, and the remaining backends are single-page.
π heads up: multiple input images can be read in two ways β from multiple input files (with the -o option), or from a single input file that holds several concatenated images.
πΈ COMPILE TIME CONFIGURATION πΈ
Some of potrace's behavior is settable at compile time by handing the following options to the ./configure script. it's giving β¨build your own destinyβ¨:
--disable-zlibβ compile potrace without the zlib compression library. This means PostScript level 3 compression will not be available. π--enable-metricβ compile potrace with centimeters as the default unit instead of inches.--enable-a4β compile potrace with A4 as the default page size.
π EXIT STATUS π
The exit status is 0 on successful completion, 1 if the command line was invalid, and 2 on any other error. simple as that, no cap π«Ά
β VERSION β
1.16
π AUTHOR π
Peter Selinger <selinger at users.sourceforge.net>
Please see the file AUTHORS for a full list of other contributors. iconic behavior from everyone involved tbh π
π§ TECHNICAL DOCUMENTATION π§
For a detailed technical description of the potrace algorithm, see the file potrace.pdf, which is available from the potrace web site. For information on the Potrace library API, see potracelib.pdf. reading material for the girlies who like to go deep πβ¨
π WEB SITE AND SUPPORT π
The latest version of potrace is available from http://potrace.sourceforge.net/. This site also contains a list of frequently asked questions, as well as information on how to obtain support. go get your answers bestie, they're right there π
π SEE ALSO π
π COPYRIGHT π
Copyright (C) 2001-2019 Peter Selinger
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 of the License, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. See also http://www.gnu.org/.
and that's the whole page, bestie π«Άβ¨ this little legend is Version 1.16, dated September 2019, and it's the potrace(1) man page β go forth and trace some bitmaps, you absolute main character ππ
π¦ where this page comes from
- alpine 3.24: potrace-doc 1.16-r2 Β· GPL-2.0-or-later
- arch rolling: potrace 1.16-5 Β· GPL-2.0-or-later
- centos-stream 10: potrace 1.16-16.el10 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- centos-stream 9: potrace 1.16-7.el9 Β· GPLv2+
- centos-stream 9: potrace 1.16-7.el9 Β· GPLv2+
- debian bookworm: potrace 1.16-2 Β· GPL-2.0-or-later
- debian trixie: potrace 1.16-2+b2 Β· GPL-2.0-or-later
- fedora 43: potrace 1.16-15.fc43 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- fedora 43: potrace 1.16-15.fc43 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- fedora 44: potrace 1.16-16.fc44 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- fedora 44: potrace 1.16-16.fc44 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- nixos 26.05: potrace 1.16
- nixpkgs unstable: potrace 1.16
- opensuse-leap 16.0: potrace 1.16-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: potrace 1.16-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: potrace 1.16-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: potrace 1.16-160000.2.2 Β· GPL-2.0-or-later
- ubuntu jammy: potrace 1.16-2 Β· GPL-2.0-or-later
- ubuntu noble: potrace 1.16-2build1 Β· GPL-2.0-or-later
- ubuntu questing: potrace 1.16-2build1
- ubuntu resolute: potrace 1.16-2build2 Β· GPL-2.0-or-later
- ubuntu stonking: potrace 1.16-2build2 Β· GPL-2.0-or-later
- Copyright (C) 2001-2019 Peter Selinger
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms