{"id":26507407,"url":"https://github.com/youngershen/easy-captcha","last_synced_at":"2025-03-20T23:19:16.606Z","repository":{"id":55338841,"uuid":"142859747","full_name":"youngershen/easy-captcha","owner":"youngershen","description":"a very easy to use captcha image generator.","archived":false,"fork":false,"pushed_at":"2020-09-02T06:54:29.000Z","size":18575,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T07:06:55.339Z","etag":null,"topics":["captcha","django","flask","web"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/youngershen.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":"2018-07-30T10:17:08.000Z","updated_at":"2024-05-29T10:11:56.000Z","dependencies_parsed_at":"2022-08-14T21:30:42.780Z","dependency_job_id":null,"html_url":"https://github.com/youngershen/easy-captcha","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngershen%2Feasy-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngershen%2Feasy-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngershen%2Feasy-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngershen%2Feasy-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/youngershen","download_url":"https://codeload.github.com/youngershen/easy-captcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244566900,"owners_count":20473450,"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","django","flask","web"],"created_at":"2025-03-20T23:19:15.927Z","updated_at":"2025-03-20T23:19:16.593Z","avatar_url":"https://github.com/youngershen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy Captcha\n\n![Travis](https://img.shields.io/travis/youngershen/easy-captcha.svg)\n![codecov](https://codecov.io/gh/youngershen/django-easy-validator/branch/master/graph/badge.svg)\n![PyPI - License](https://img.shields.io/pypi/l/easy-captcha.svg)\n![PyPI](https://img.shields.io/pypi/v/easy-captcha.svg)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/easy-captcha.svg)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/easy-captcha.svg)\n![GitHub last commit](https://img.shields.io/github/last-commit/youngershen/easy-captcha.svg)\n\n------\n\n## What is it\n\nthis is a very easy to use python package that helps you to generate the image captchas, in the help of this package you\ncan easily make your own captcha design rather than the default design.\n\n## Python supported\n\n* CPYTHON 3.6\n* CPYTHON 3.7\n\n## Installation\n\n* pip install easy-captcha\n* python setup.py install\n\n## Quick start\n\n```python\n    from captcha.generator import DefaultGenerator\n    generator = DefaultGenerator()\n    captcha = generator.make_captcha(string='ABCD')\n    captcha.save('test-default.png')\n```\n\nthe make_captcha method return a PIL Image object, you\ncan save it with your any type you wanted, easy to use.\n\n## Samples\n\n    from captcha import DefaultGenerator\n\n![Default](assets/test-default.png)\n\n    from captcha import SimpleGenerator\n\n![Simple](assets/test-simple.png)\n\n    from captcha import SimpleChineseGenerator\n\n![Simple](assets/test-simple-chinese.png)\n\n## Advance topic\n\n### Custom font\n\n```python\n    from pathlib import Path\n    from captcha.generator import DefaultGenerator\n\n    class MyCaptchaGenerator(DefaultGenerator):\n        def _get_font(self, size):\n            p = Path('./fonts/test.otf')\n            font = self._load_font(path=p, size=size)\n            return font\n```\n\nif you just want to use your font instead of the default font,\njust reimplement the _get_font method, make the method return\nyour font.\n\n### Custom captcha generator\n\nif you want to custom the captcha generator, you just need to subclass the **captcha.generator.BaseGenerator** class. when\nyou subclass the **BaseGenerator** then you could use the method\ninside the **BaseGenerator** to make your own style captcha genrator.\n\nif the default drawing methods are not well enough for you, you\ncould just use the **pillow** staff to make your own generator.\nthis whole package is based on **pillow**, so just feel free to\nmodify it.\n\nfor more details just check the code below. the important thing\nis that when you subclass the **BaseGenerator**, you just need\nto implement the **make_captcha** method and **_get_font** method.\n\n```python\nclass DefaultGenerator(BaseGenerator):\n    FONT = 'TruenoBdOlIt.otf'\n\n    def make_captcha(self,\n                     string: str = None,\n                     font_size: int = 48,\n                     image_size: tuple = None):\n        captcha = self._make_captcha(string, font_size)\n        size = image_size if image_size else self.size\n        captcha = self._resize(captcha, size)\n        return captcha\n\n    def _make_captcha(self, string, font_size):\n        font = self._get_font(font_size)\n        char_images = self._make_char_images(string,\n                                             font,\n                                             rotate=None,\n                                             color=self._rand_color)\n        image = self._composite_char_images(char_images,\n                                            color=self._get_color(255,\n                                                                  255,\n                                                                  255))\n\n        self._rand_noise_lines(image, number=3)\n        return image\n\n    def _get_font(self, size: int):\n        font = self._load_font(name=self.FONT, size=size)\n        return font\n```\n\n## Future support feature\n\n- [x] Basic png captcha support.\n- [ ] GIF format support.\n- [ ] Audio format support.\n- [x] Django framework intergration, see [this](https://github.com/youngershen/django-easy-captcha).\n- [ ] Flask framework intergration.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoungershen%2Feasy-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoungershen%2Feasy-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoungershen%2Feasy-captcha/lists"}