This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Wrapper and wrapper generators for the 2D Image Leptonica Library

Project Description

This is a thin ctypes wrapper over the Leptonica library. ( Almost all functions are exposed to Python, correctly anotated, and data structures used in Leptonica are available as classes from Python.

This Library is licensed under the Lesser GNU Public License Version 3 or Later.

Leptonica data structures are available as authomaticaly generated Python objects, transparently calling Leptonica’s constructors and Detrutors when those exist.

Threfore for a new image object (represented in Leptonica as a “PIX” structure). one just jave to do: image = leptonica.PIX(640, 480,32) This will have the same effect than manually calling the constructor as in:

image = leptonica.functions.pixCreate(640,480,32)

It transposes Leptonica’s extensive inline documentation to Python’s docstrings, so it is possible to check for help and parameter types from the Python interpreter, using pydoc or from an IDE.

However, whenever a function takes pointers or arrays of pointers as parameters, these will have to be created by hand using ctypes facilities before calling the functions. (Except for pointers to Leptonica data structures: these are translated into fairly high-level Python objects).

This is on an already usable stage, although one might expect some API changes and inclusion of more “pure python” utility functions. The main behavior of the Leptonica objetcs should remain the same.

To run it, you might not need to have Leptonica source files: I versioned the generated files as well so that most people just have to copy the .py files around. If you want to hack the code, or generate wrappers for other versions of Leptonica, you have to execute the and as stand alone programs, after tunning a from the file.

There are at this time, two utility functions to convert Leptonica images to and from Python Imaging Library (PIL) Images.

Also, although I have not tested this under windows or Mac OS– it probably need some tweaks to run (mostly finding the correct libraries with ctypes) - but otherwise it should plainly work.

Have fun!

js -><-
Release History

Release History

This version
History Node


History Node


Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting