Skip to main content

A simple CAPTCHA image generator

Project description

Simple CAPTCHA generator package.

This module provides a single class (Claptcha) that can create on the fly PIL Image instances, BytesIO objects or save image files containing a simple CAPTCHA strings. Its build on top of Pillow package.

It is required that user provides a TTF file with font to be used in images and either a string with CAPTCHA text or a callable object returning strings to be used in images.

Examples:

>>> from claptcha import Claptcha
>>>
>>> # Initialize Claptcha object
>>> c = Claptcha("Text", "FreeMono.ttf")
>>>
>>> # Create a PIL Image object, return it and provided text
>>> c.image
('Text', <PIL.Image.Image image mode=RGB size=200x80 at 0xB741406C>)
>>>
>>> # Create a BytesIO object, return it and provided text
>>> c.bytes
('Text', <_io.BytesIO object at 0xb71e87dc>)
>>>
>>> # Save image in 'claptcha.png' file, return its path and provided text
>>> c.write('claptcha.png')
('Text', 'test.png')
>>>
>>> def captchaStr():
...     return "TextFromFunc"
...
>>> # Redefine c: change its size to 100x30, use nearest resampling filter
>>> # and add white noise
>>> from PIL import Image
>>> c = Claptcha(captchaStr, "FreeMono.ttf", (100,30),
...              resampling=Image.NEAREST, noise=0.3)
>>> c.image
('TextFromFunc', <PIL.Image.Image image mode=RGB size=100x30 at 0xB73EE66C>)

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

claptcha-0.3.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

claptcha-0.3.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file claptcha-0.3.2.tar.gz.

File metadata

  • Download URL: claptcha-0.3.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for claptcha-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6a243eed1f0ee008836bf96cec1d210fcea53b39cc4dda1dbc8c32d242e30984
MD5 49d63f03e23dd01c2230d8fb602c76a2
BLAKE2b-256 e4959782db55b3736e42fb0b397b8a5ccb72af90a23b2b44e622cc61966dc82e

See more details on using hashes here.

File details

Details for the file claptcha-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for claptcha-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2aa4c08379834d1d08f20292e959972a901d863afce23c682c2474b353b58b5e
MD5 16ce69bfd6e4287f782cec24643a52f9
BLAKE2b-256 5b69b43c8da3463c9f971a60271fa8d1ac7123fe8900738f07af55c7a9d34e40

See more details on using hashes here.

Supported by

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