Skip to main content
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()

Metadata

Release files for wsy_captcha 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wsy_captcha 1.0.0
File Size Uploaded
wsy_captcha-1.0.0.tar.gz 59.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wsy_captcha 1.0.0
File Interpreter ABI Platform
wsy_captcha-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 121.5 kB

Release files / wsy_captcha-1.0.0.tar.gz

Download URL wsy_captcha-1.0.0.tar.gz
Size 59.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cabe1ed099563d547c6f87d5940d40c46b57e2eff8a4abfc9cde3ecd7d6e7527
BLAKE2b-256 checksum
How to use checksums
147509f4bcf57e6de679bca149600cdba53aad7b076446eec2965e0e95262378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / wsy_captcha-1.0.0-py3-none-any.whl

Download URL wsy_captcha-1.0.0-py3-none-any.whl
Size 61.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
511724420e362566d7a4c85f42e86ff57a0364176a628954d796dd6f342081e0
BLAKE2b-256 checksum
How to use checksums
f4f48fbb4ee5b03be4a497bea513e8f289c3fab2c978b26c056098cdca4f9f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page