View Source Captcha (captcha v0.1.4)
Crate to generate CAPTCHAs.
Easy example:
iex> {chars, png} = Captcha.easy()
{"SnZw8", <<...>>}
iex> File.write!("captcha.png", png)
:ok
Or create by custom chars:
iex> Captcha.easy(set_color: %{r: 0, g: 116, b: 204})
{"SnZw8", <<...>>}
Create by options:
iex> Captcha.create(
...> set_chars: "123456789abcdefgABCDEFG",
...> add_chars: 6,
...> set_color: %{r: 0, g: 116, b: 204},
...> view: %{w: 220, h: 120},
...> filters: [filter, ...]
...> )
{"78a23G", <<...>>}
Summary
Types
supported chars: "123456789ABCDEFGHJKMNPQRSTUVWXYZabcdefghijklmnpqrstuvwxyz"
Functions
Create png image by options
Create easy image
Create hard image
Create medium image
Supported Chars
Types
@type chars() :: String.t()
supported chars: "123456789ABCDEFGHJKMNPQRSTUVWXYZabcdefghijklmnpqrstuvwxyz"
exclude chars: 0, O, o, L, i
@type difficulty() :: :easy | :medium | :hard
@type filter() :: Captcha.Native.Filter.Cow.t() | Captcha.Native.Filter.Dots.t() | Captcha.Native.Filter.Grid.t() | Captcha.Native.Filter.Noise.t() | Captcha.Native.Filter.Wave.t()
@type name() :: :amelia | :lucy | :mila
@type options() :: [ set_chars: chars(), add_chars: non_neg_integer(), set_color: %{r: non_neg_integer(), g: non_neg_integer(), b: non_neg_integer()}, view: %{w: non_neg_integer(), h: non_neg_integer()}, filters: [filter()] ]
@type png() :: binary()
Functions
Create png image by options
example:
iex> Captcha.create(
...> set_chars: "123456789abcdefgABCDEFG",
...> add_chars: 6,
...> set_color: %{r: 0, g: 116, b: 204},
...> view: %{w: 220, h: 120},
...> filters: [filter, ...]
...> )
{"SnZw8", <<...>>}
@spec create_by_name(name(), difficulty(), options()) :: return()
Create by name
example:
iex> Captcha.create_by_name(:lucy)
{"SnZw8", <<...>>}
Create easy image
example:
iex> Captcha.easy()
{"SnZw8", <<...>>}
Create hard image
example:
iex> Captcha.hard()
{"SnZw8", <<...>>}
Create medium image
example:
iex> Captcha.medium()
{"SnZw8", <<...>>}
@spec supported_chars() :: binary()
Supported Chars
Not support chars: 0, O, o, L, i
example:
iex> Captcha.supported_chars()
"123456789ABCDEFGHJKMNPQRSTUVWXYZabcdefghijklmnpqrstuvwxyz"