Module ecaptcha

Main interface for Erlang captcha library.

Description

Main interface for Erlang captcha library

Data Types

color_name()

color_name() = ecaptcha_color:color_name()

color_rgb()

color_rgb() = ecaptcha_color:rgb()

err_reason()

err_reason() = chars_not_binary | wrong_chars_length | invalid_character | bad_random | small_rand_binary | opts_not_list | non_atom_option | unknown_option

opts()

opts() = [line | blur | filter | dots | reverse_dots]

line - draws a curved horisontal line on top of the text blur - blurs the image (averages each pixel's color with it's neighbours) filter - makes letters hollow dots - draws 100 random 2x2 white dots on top of the image, effectively removing small pathes from it reverse_dots - draws 20 random dots of a randomized size from 1 to 3px using a color opposite to the current color (so, reversing the color - black becomes white, white becomes black)

Function Index

gif/3Generate GIF image 200x70 with NumChars letters on it.
pixels/2Generate greyscale array of pixels 200x70.
png/3Generate PNG image 200x70 with NumChars letters on it.

Function Details

gif/3

gif(NumChars::pos_integer(), Opts::opts(), Color::color_name() | color_rgb()) -> {Str::binary(), GifImg::binary()} | {error, err_reason()}

Generate GIF image 200x70 with NumChars letters on it

Same as png/3, but image is in GIF format.

pixels/2

pixels(NumChars::pos_integer(), Opts::opts()) -> {Str::binary(), Pixels::binary()} | {error, err_reason()}

NumChars: how many characters should be on a image, 1..6
Opts: list of additional effects to apply to the image

Generate greyscale array of pixels 200x70

It returns a tuple where 1st element is a binary ASCII string which contains characters that are printed on captcha image. 2nd element is a plain binary that contains 200x70 = 14000 "pixels", 1 byte each, where 0 means black and 255 - white, intermediate values are shades of grey.

png/3

png(NumChars::pos_integer(), Opts::opts(), Color::color_name() | color_rgb()) -> {Str::binary(), PngImg::binary()} | {error, err_reason()}

NumChars: - same as in pixels/2
Opts: - same as in pixels/2
Color: - use shades of this color instead of shades of grey. Can be one from the set of recommended named colors or {Red, Green, Blue} RGB tuple

Generate PNG image 200x70 with NumChars letters on it

It returns a 2-tuple where 1st element is the binary containing of NumChars size containing ASCII string that is printed on the image and 2nd element is PNG-encoded image that can be, eg sent directly to the browser with Content-Type: image/png.


Generated by EDoc