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
Release history Release notifications | RSS feed
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.1.tar.gz
(1.7 kB
view details)
Built Distribution
File details
Details for the file claptcha-0.3.1.tar.gz
.
File metadata
- Download URL: claptcha-0.3.1.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e9d2920e7d4e42197062fecd2d8494ae5d45dbacaa5a7cae24b410d97eadc637
|
|
MD5 |
ed8952d8c4141144f51925eb60d2fad0
|
|
BLAKE2b-256 |
163d0db85d7a8b1d505430b08333220f5bd238f9b9937114e5da53aa3cc0d70a
|
File details
Details for the file claptcha-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: claptcha-0.3.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
2d360196e7c3dc45300fbfaee4e1c0b4c213b0112cff5dd5c9852bc3c0dabc65
|
|
MD5 |
8ba66389e87a1ee2407502fa9c585a80
|
|
BLAKE2b-256 |
8f19b45275d0a7356caa84dd107480a0a5b78dcf863e634710a603bd0c91e346
|