You are looking at historical revision 20630 of this page. It may differ significantly from its current revision.

Leptonica

In progress.

An interface to the leptonica library of routines for image analysis and processing.

Memory Management

Most of the library's operations are based around manipulating images, which are stored in a structure known as a pix. You should manually manage the references to the images. If you want a copy of an existing pix, use pix-clone; this updates the reference count for an image. Use pix-destroy when you are finished with a reference to a pix; this decrements the reference count, and finally deletes the image when the count is 0.

Implemented Procedures

Creating and managing images

[procedure] (pix-clone pix)

Return a reference to given pix.

[procedure] (pix-copy pix-d pix-s)

Makes a copy of pix-s: if pix-d is #f then returns a pointer to a copy of pix-s, else makes pix-d a copy of pix-s.

[procedure] (pix-create width height depth)

Returns a pointer to a new pix, an image of given width and height in pixels, and colour depth.

[procedure] (pix-destroy pix)

Reduces reference count to pix, and destroys picture if count is 0.

[procedure] (pix-read filename)

Returns a pointer to a new pix created by reading image from filename. Returns #f if there is an error.

[procedure] (pix-save filename pix image-type)

Writes pix to an image file called filename. The image-type is taken from the list of constants, below.

Image attributes

[procedure] (pix-get-width pix)

Returns the width in pixels of given pix.

[procedure] (pix-set-width pix integer)

Sets the width in pixels of given pix. Returns 0 if ok, or 1 if error.

[procedure] (pix-get-height pix)

Returns the height in pixels of given pix.

[procedure] (pix-set-height pix integer)

Sets the height in pixels of given pix. Returns 0 if ok, or 1 if error.

[procedure] (pix-get-depth pix)

Returns the colour depth of given pix.

[procedure] (pix-set-depth pix integer)

Sets colour depth of given pix. Returns 0 if ok, or 1 if error.

[procedure] (pix-set-dimensions pix width height depth)

Sets all three properties of given pix. Returns 0 if ok, or 1 if error.

[procedure] (pix-get-x-res pix)

Returns the x resolution of given pix.

[procedure] (pix-set-x-res pix integer)

Sets the x resolution of given pix. Returns 0 if ok, or 1 if error.

[procedure] (pix-get-y-res pix)

Returns the y resolution of given pix.

[procedure] (pix-set-y-res pix integer)

Sets the y resolution of given pix. Returns 0 if ok, or 1 if error.

[procedure] (pix-set-resolution pix x-res y-res)

Sets the x and y resolution of given pix. Returns 0 if ok, or 1 if error.

[procedure] (pix-scale-resolution pix x-scale y-scale)

Rescales the image in the x and y directions. Returns 0 if ok, or 1 if error.

[procedure] (pix-get-input-format pix)

Returns the input format of pix.

[procedure] (pix-set-input-format pix integer)

Sets the input format of pix.

Manipulating images

[procedure] (rotate pix angle rotation-type in-colour width height)

Returns a pointer to a new pix created by rotating given pix.

[procedure] (scale pix scale-x scale-y)

Returns a pointer to a new pix created by rescaling given pix along x and y dimensions.

Constants

image-type
IFF-UNKNOWN, IFF-BMP, IFF-JFIF-JPEG, IFF-PNG, IFF-TIFF, IFF-TIFF-PACKBITS, IFF-TIFF-RLE, IFF-TIFF-G3, IFF-TIFF-G4, IFF-TIFF-LZW, IFF-TIFF-ZIP, IFF-PNM, IFF-PS, IFF-GIF, IFF-JP2, IFF-DEFAULT, IFF-SPIX.
in-colour
L-BRING-IN-WHITE, L-BRING-IN-BLACK.
rotation-type
L-ROTATE-AREA-MAP, L-ROTATE-SHEAR, L-ROTATE-SAMPLING.

Examples

See the examples folder in the repository.

Author

Peter Lane

License

GPL version 3.0.

Requirements

You will need libraries for handling images: libjpeg, libpng, libtiff are currently assumed in the setup file.

Also, you must download and compile the source code for the leptonica library.

Note: this egg has only been tested under Linux.

Version History