{"id":20100609,"url":"https://github.com/seriyps/ecaptcha","last_synced_at":"2025-09-20T13:31:44.931Z","repository":{"id":57492440,"uuid":"318353935","full_name":"seriyps/ecaptcha","owner":"seriyps","description":"Zero-dependency Erlang library that generates captcha images","archived":false,"fork":false,"pushed_at":"2023-10-04T13:33:54.000Z","size":204,"stargazers_count":13,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-03T16:23:44.845Z","etag":null,"topics":["captcha","erlang","gif","png"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seriyps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-04T00:08:48.000Z","updated_at":"2024-12-30T06:06:56.000Z","dependencies_parsed_at":"2022-09-02T00:22:56.138Z","dependency_job_id":null,"html_url":"https://github.com/seriyps/ecaptcha","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriyps%2Fecaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriyps%2Fecaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriyps%2Fecaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriyps%2Fecaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seriyps","download_url":"https://codeload.github.com/seriyps/ecaptcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233665635,"owners_count":18710919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captcha","erlang","gif","png"],"created_at":"2024-11-13T17:16:28.036Z","updated_at":"2025-09-20T13:31:39.562Z","avatar_url":"https://github.com/seriyps.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"ecaptcha\n=====\n\nSimple [Captcha](https://en.wikipedia.org/wiki/CAPTCHA) image generator for Erlang.\n\nZero dependencies! Pixels are generated by tiny C NIF. GIF and PNG encoders are pure-Erlang.\n\nFlexible additional effects, multiple fonts, arbitrary colors, latin alphanumerics set of characters.\n\nCovered by property-based tests. No segfaults, no memory-leaks.\n\nBased on [Ivan Tikhonov's captcha library](https://github.com/ITikhonov/captcha).\n\nUsage\n-----\n\nAdd `ecaptcha` as a dependency to your project's rebar.config:\n\n```erlang\n{deps, [ecaptcha]}.\n```\n\nThen use one of the API functions to generate the image and short random text:\n\n```erlang\n{Phrase, PNGImage} = ecaptcha:png(\n    5,\n    #{effects =\u003e [line, blur, filter, dots, reverse_dots],\n      color =\u003e black,\n      alphabet =\u003e latin_uppercase,\n      font =\u003e \u003c\u003c\"dejavusans\"\u003e\u003e}\n).\n```\n\n`PNGImage` can be sent to the user with `Content-Type: image/png` and user have to guess\nthe 5-letter `Phrase` which is printed on the image.\n\n`effects` option defines a set of different effects, which suppose to make it more difficult to\nrecognize the text with OCR systems:\n\n* `line` - draws a curved horisontal line on top of the text\n* `blur` - blurs the image (averages each pixel's color with it's neighbours)\n* `filter` - makes letters hollow\n* `dots` - draws 100 random 2x2 white dots on top of the image, effectively removing small patches\n  from it\n* `reverse_dots` - draws 20 random dots of a randomized size from 1 to 3px using a color opposite\n  to the current color (so, reversing the color - black becomes white, white becomes black)\n\nThe more effects you apply, the more difficult it is to recognize the text on the image (for both\nhuman and OCR).\n\n`color` option defines the image's color. It doesn't affect Captcha strength, but can be used to match\nyour website / app style. You can select from a set of predefined colors: `black`, `red`, `orange`,\n`blue`, `pink` or `purple`, or it can be provided as a 3-tuple `{Red, Green, Blue}`, `0..255`.\n\n`alphabet` defines the set of characters that can be printed on the image. It can be one of the\npredefined sets: `numbers` for 0-9, `latin_lowercase` for a-z, `latin_uppercase` for A-Z or it\ncan be a binary containing all the allowed characters (duplicates are ok), eg `\u003c\u003c\"1234abcd\"\u003e\u003e`.\n\n`font` binary name of one of the supported fonts. Function `fonts/0` can be used to get the list of\navailable fonts. Fonts are pre-rendered at NIF compile-time, see the `c_src/fonts.h` and\n`FONTS` parameter in `c_src/Makefile`.\n\nAll the options are optional.\n\n```erlang\necaptcha:gif/2\n```\n\nSame as `ecaptcha:png/2`, but returns the image encoded in GIF format. `Content-Type: image/gif`.\n\n```erlang\n{Phrase, Pixels} = ecaptcha:pixels(5, #{font =\u003e \u003c\u003c\"ubuntu-r\"\u003e\u003e, alphabet =\u003e numbers}).\n```\n`Phrase` is the same as above, but `Pixels` is a `200x70 = 14000` bytes binary of greyscale\npixels, from top-left to bottom-right, line-by-line. It can be used to, eg, display pixels with\nJavaScript on a `\u003ccanvas\u003e` etc. Options are the same as for `gif/2` or `png/2`, but `color` key\nis obviously ignored.\n\n```erlang\necaptcha:fonts()\n```\n\nReturns a list of tuples containing information about each available font. Currently it's a 2-tuple\nwhere 1st element is binary font name and 2nd element is binary containing all the characters of\nthe alphabet available for this font.\n\nImage encoders\n--------------\n\nThis library also contains pure-erlang PNG and GIF image format encoders.\nSee [ecaptcha_gif.erl](src/ecaptcha_gif.erl) and [ecaptcha_png.erl](src/ecaptcha_png.erl).\nTheir current API is not really a generic-purpose, but the implementation is quite flexible, so,\ncode can be adopted to encode arbitrary images, not only Captchas.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseriyps%2Fecaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseriyps%2Fecaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseriyps%2Fecaptcha/lists"}