alphabet() = numbers | latin_lowercase | latin_uppercase | alphabet_bin()
alphabet_bin() = binary()
color_name() = ecaptcha_color:color_name()
color_rgb() = ecaptcha_color:rgb()
effects() = [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)
err_reason() = font_name_not_binary | font_not_found | chars_not_binary | wrong_chars_length | character_out_of_alphabet_range | bad_random | small_rand_binary | opts_not_list | non_atom_option | unknown_option
font_name() = binary()
opts() = #{color => color_name() | color_rgb(), effects => effects(), font => font_name(), alphabet => alphabet()}
| fonts/0 | List avaliable fonts. |
| gif/2 | Generate GIF image 200x70 with NumChars letters on it. |
| pixels/2 | Generate greyscale array of pixels 200x70. |
| png/2 | Generate PNG image 200x70 with NumChars letters on it. |
fonts() -> [{font_name(), alphabet_bin()}, ...]
List avaliable fonts
Returns a list of tuples where the 1st element is the font name and 2nd elemnt is the binary containing all the available characters of this font. Format may change in the future.gif(NumChars::pos_integer(), Opts::opts()) -> {Str::binary(), GifImg::binary()} | {error, err_reason()}
Generate GIF image 200x70 with NumChars letters on it
Same aspng/3, but image is in GIF format.
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: map of additional options such as font, alphabet and effects
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(NumChars::pos_integer(), Opts::opts()) -> {Str::binary(), PngImg::binary()} | {error, err_reason()}
NumChars: - same as in pixels/2
Opts: - same as in pixels/2, but also includes color. See opts().
Generate PNG image 200x70 with NumChars letters on it
It returns a 2-tuple where 1st element is the binary containing ofNumChars 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