Package: pypotrace-windows
These bindings provide an object oriented API to thepotracelibrary.The full API documentation is onhttps://pythonhosted.org/pypotrace/.Example usageThe bindings work with input images represented as numpy arrays:import numpy as np
import potrace

# Make a numpy array with a rectangle in the middle
data = np.zeros((32, 32), np.uint32)
data[8:32-8, 8:32-8] = 1

# Create a bitmap from the array
bmp = potrace.Bitmap(data)

# Trace the bitmap to a path
path = bmp.trace()

# Iterate over path curves
for curve in path:
    print "start_point =", curve.start_point
    for segment in curve:
        print segment
        end_point_x, end_point_y = segment.end_point
        if segment.is_corner:
            c_x, c_y = segment.c
        else:
            c1_x, c1_y = segment.c1
            c2_x, c2_y = segment.c2InstallationUbuntuInstall system dependencies:$ sudo apt-get install build-essential python-dev libagg-dev libpotrace-dev pkg-configInstall pypotrace:$ git clone https://github.com/flupke/pypotrace.git
$ cd pypotrace
$ pip install numpy
$ pip install .CentOS/RedHatInstall system dependencies:$ sudo yum -y groupinstall "Development Tools"
$ sudo yum -y install agg-devel potrace-devel python-develInstall pypotrace:$ git clone https://github.com/flupke/pypotrace.git
$ cd pypotrace
$ pip install numpy
$ pip install .OSXInstall system dependencies:$ brew install libagg pkg-config potraceInstall pypotrace:$ git clone https://github.com/flupke/pypotrace.git
$ cd pypotrace
$ pip install numpy
$ pip install .WindowsThanks toklonuofor the instructionsHere are instruction how to make this package work on Windows, by using MinGW
system. Probably it can be done with Visual Studio, but I lack skills to make
such magic.So assuming user has MinGW available, additional two packages are needed:potrace source:http://potrace.sourceforge.net/#downloadingagg source:http://www.antigrain.com/download/index.htmlI extracted both packages in myC:\srcfolder. Both are easy to build by
executing./configure; makeand./autogen.sh; makerespectively, on
MSYS prompt.After that, we need some variables to build pypotrace successfully:First, includes paths:“numpy/arrayobject.h”:C:/Python27/Lib/site-packages/numpy/core/includepotrace headers:C:/src/potrace-1.11/srcagg headers:C:/src/agg-2.5there is a little catch for agg includes, as paths referenced in cpp sources
point toagg2/*.hwhile in downloaded agg package we don’t haveagg2folder. For me it was easiest to renameC:/src/agg-2.5/includetoC:/src/agg-2.5/agg2and useC:/src/agg-2.5as agg include folder.Next, libdirs for libraries we build above:potrace:C:/src/potrace-1.11/src/.libsagg:C:/src/agg-2.5/srcand we can make pypotrace build command, and execute it:python setup.py build_ext -IC:/Python27/Lib/site-packages/numpy/core/include;C:/src/potrace-1.11/src;C:/src/agg-2.5 -LC:/src/potrace-1.11/src/.libs;C:/src/agg-2.5/srcFinally install the package:C:\src\git\pypotrace>python setup.py install
running install
running build
running build_py
copying potrace\__init__.py -> build\lib.win32-2.7\potrace
copying potrace\agg\__init__.py -> build\lib.win32-2.7\potrace\agg
running build_ext
skipping 'potrace\_potrace.c' Cython extension (up-to-date)
skipping 'potrace\bezier.cpp' Cython extension (up-to-date)
skipping 'potrace/agg\curves.cpp' Cython extension (up-to-date)
running install_lib
creating C:\Python27\Lib\site-packages\potrace
creating C:\Python27\Lib\site-packages\potrace\agg
copying build\lib.win32-2.7\potrace\agg\curves.pyd -> C:\Python27\Lib\site-packages\potrace\agg
copying build\lib.win32-2.7\potrace\agg\__init__.py -> C:\Python27\Lib\site-packages\potrace\agg
copying build\lib.win32-2.7\potrace\bezier.pyd -> C:\Python27\Lib\site-packages\potrace
copying build\lib.win32-2.7\potrace\_potrace.pyd -> C:\Python27\Lib\site-packages\potrace
copying build\lib.win32-2.7\potrace\__init__.py -> C:\Python27\Lib\site-packages\potrace
byte-compiling C:\Python27\Lib\site-packages\potrace\agg\__init__.py to __init__.pyc
byte-compiling C:\Python27\Lib\site-packages\potrace\__init__.py to __init__.pyc
running install_egg_info
Writing C:\Python27\Lib\site-packages\pypotrace-0.1-py2.7.egg-infoRunning testsYou can check everything is working correctly by running the tests:$ pip install '.[dev]'
$ nosetests -vDocumentationThe documentation is hosted here:http://packages.python.org/pypotraceA copy is also included in thedoc/_build/htmldirectory of the source
distribution.HomepageThis project is hosted on github:http://github.com/flupke/pypotrace