Skip to main content

A library that generates image captcha.

Project description

wsy_captcha
===================

A library that generates image captcha.

.. image:: https://raw.githubusercontent.com/wushuyi/wsy_captcha/master/test.png

Installation
------------

Install wsy_captcha with pip::

$ pip install wsy_captcha

Base Usage
-----
.. code:: python

from wsy_captcha.comp import print_
from wsy_captcha.captcha import Captcha

captcha = Captcha()
code = captcha.randomCode()
print_(code)
captcha.write(code, 'test.png')

Advanced Usage
-----
.. code:: python

from wsy_captcha.comp import print_
from wsy_captcha.captcha import Captcha
import wsy_captcha.image as image


class MyCaptcha(Captcha):
def generate_image(self, chars):
text_drawings = [
image.warp(),
image.rotate(),
image.offset(),
]
fn = image.captcha(
drawings=[
image.background(color='#FFFFFF'),
image.text(fonts=self._fonts, drawings=text_drawings),
image.curve(width=2),
image.curve(width=2),
image.curve(width=2),
image.noise(number=60, color='#5C87B2', level=2),
image.smooth(),
],
width=self._width,
height=self._height,
)
return fn(chars)


captcha = MyCaptcha()
code = captcha.randomCode()
img = captcha.generate(code)
print_(code)
f = open('test.png', 'wb')
f.write(img.read())
f.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsy_captcha-1.0.0.tar.gz (59.8 kB view details)

Uploaded Source

Built Distribution

wsy_captcha-1.0.0-py3-none-any.whl (61.6 kB view details)

Uploaded Python 3

File details

Details for the file wsy_captcha-1.0.0.tar.gz.

File metadata

  • Download URL: wsy_captcha-1.0.0.tar.gz
  • Upload date:
  • Size: 59.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wsy_captcha-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cabe1ed099563d547c6f87d5940d40c46b57e2eff8a4abfc9cde3ecd7d6e7527
MD5 087e2d807980670647c43b575bc7b4a1
BLAKE2b-256 147509f4bcf57e6de679bca149600cdba53aad7b076446eec2965e0e95262378

See more details on using hashes here.

File details

Details for the file wsy_captcha-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wsy_captcha-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 511724420e362566d7a4c85f42e86ff57a0364176a628954d796dd6f342081e0
MD5 4e0a3e97b547bce34304a0d62bfa45f7
BLAKE2b-256 f4f48fbb4ee5b03be4a497bea513e8f289c3fab2c978b26c056098cdca4f9f1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page