Skip to main content

potrace Python bindings

Project description

These bindings provide an object oriented API to the potrace library.

Example usage

The 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.c2

Installation

Make sure you have the agg and potrace development packages installed (libagg-dev and libpotrace-dev on ubuntu) and run:

python setup.py install

Documentation

The documentation is hosted here: http://packages.python.org/pypotrace

A copy is also included in the doc/_build/html directory of the source distribution.

Homepage

This project is hosted on github: http://github.com/flupke/pypotrace

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypotrace-0.1.tar.gz (191.0 kB view details)

Uploaded Source

File details

Details for the file pypotrace-0.1.tar.gz.

File metadata

  • Download URL: pypotrace-0.1.tar.gz
  • Upload date:
  • Size: 191.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pypotrace-0.1.tar.gz
Algorithm Hash digest
SHA256 5761e6b60bc8d9e6870aafb65184df57bac46a99287a2aa126162a9eb84376b4
MD5 4b8dd2656691abc9cd769efd7652e69b
BLAKE2b-256 0105a444e108b9bc645fafd02c52eac81bb0b1ed23dc504ca70fad61d6706c57

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page