Image and Audio captcha generation using python
Initialisation with captcha customisation arguments
image = ImageCaptcha()
c_height=200, c_width=600
Use hexadecimal colors, HTML color names, etc, use Pil ImageColor Documents for more details on color name.
c_color
Provide a ttf font path
font_type
font_color
font_size
String lenght for random captcha string. Inoperative if captch string is passed to generate function.
string_length
Fo random captcha String. provides a combination of string to include in the captcha example Lower case("L"), Upper Case("U"), Numeric("D"), Symbols("P "). Inoperative if captch string is passed to generate function.
string_constants=("U", "L", "D")
Generates captcha. If captcha string is not passed, generates a random string from Upper Case, Lower Case, and Number. The Specify noise density for noise on the captcha. Integer value represents the number of noise pixels on the captcha.
Returns captcha string
captcha_string = image.save_image(captcha_string, noise_density)
To see the Captcha Image
image.show_image()
Convert the image to bytes. The encoder argument defaults to "raw" Returns bytes
image_byte = image.im_bytes(encoder="raw")
text_to_speech = TextToSpeech(string_length=6, string_constants=("L", "D"))
text_to_speech.gen_audio(filename="aud.mp3", captcha_string=None)
Using Pillow Python Imaging library for creating captcha images
For Text to Speech using gTTS
Fonts from Google Fonts