Free software projects:
Python extension to generate captcha images
Python extension to get preview images from Theora videos in Ogg files
Python extension to capture video with video4linux2
Karaoke game
Web projects (Swedish):
email: fredrik@jemla.se
Python extension to generate captcha images
Source code: captchaimage-1.3.tar.gz (4 kB)
License: Public domain. See notice in each file.
Email: fredrik@jemla.se
Example image:

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 uses distutils.
python-captchaimage requires the library Freetype 2.
http://freetype.org
To build: ./setup.py build
To build and install: ./setup.py install
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
# Black text on white background
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()
# Arbitrary colors, in the formats PIL accepts
def get_color_captcha_image(code, background_color, text_color):
size_y = 32
image_data = captchaimage.create_image(
"/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 28, size_y, code)
size_x = len(image_data) / size_y
file = cStringIO.StringIO()
mask_im = Image.fromstring("L", (size_x, size_y), image_data)
target_im = Image.new("RGB", (size_x, size_y), text_color)
target_im.paste(background_color, (0, 0), mask_im)
target_im.save(file, "JPEG", quality = 30)
return file.getvalue()
# Example: Magenta text on yellow background
# get_color_captcha_image("TESTING", (255, 255, 0), (255, 0, 255))