captchaimage 1.2 - Python extension to generate captcha images

2008 Fredrik Portstrom

I, the copyright holder of this file, hereby release it into the
public domain. This applies worldwide. In case this is not legally
possible: I grant anyone the right to use this work for any purpose,
without any conditions, unless such conditions are required by law.

Introduction
============

python-captchaimage is a fast and easy to use Python extension for
creating images with distorted text that are easy for humans and
difficult for computers to read. Glyphs are loaded as bezier curves
using Freetype, rotated and scaled randomly, and then distorted by
adding Perlin noise to each point of the curve before rendering into a
bitmap. python-captchaimage generates about 950 images a second on a
1800 MHz Intel Celeron.

python-captchaimage: http://fredrik.jemla.eu/captchaimage

Freetype: http://freetype.org

Installation
============

python-captchaimage uses distutils.
python-captchaimage requires the library Freetype 2. http://freetype.org
To build: ./setup.py build
To build and install: ./setup.py install

Example
=======

To get a string containing a JPEG formatted image: It as a number
of lines, but it's just to copy and paste, and maybe change the
font face.

import captchaimage
import cStringIO
import Image

def get_captcha_image(code):
    size_y = 32
    image_data = captchaimage.create_image(
        "/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 28, size_y, code)
    file = cStringIO.StringIO()
    Image.fromstring(
        "L", (len(image_data) / size_y, size_y), image_data).save(
        file, "JPEG", quality = 30)
    return file.getvalue()

Change log
==========

1.2 (2009-11-03) - Fixed reference to the wrong variable. Updated URL.

1.1 (2008-09-13) - Fixed bug causing python-captchaimage to crash.

1.0 (2008-07-30) - Initial release.
