Skip to main content

安装

pip install gvcode

例子

from gvcode import VFCode



if __name__ == '__main__':
    vc = VFCode(
        width=200,                       # 图片宽度
        height=80,                       # 图片高度
        fontsize=50,                     # 字体尺寸
        font_color_values = [
                '#ffffff',
                '#000000',
                '#3e3e3e',
                '#ff1107',
                '#1bff46',
                '#ffbf13',
                '#235aff'
            ],                           # 字体颜色值
        font_background_value='#ffffff', # 背景颜色值
        draw_dots=False,                 # 是否画干扰点
        dots_width=1,                    # 干扰点宽度
        draw_lines=True,                 # 是否画干扰线
        lines_width=3,                   # 干扰线宽度
        mask=False,                      # 是否使用磨砂效果
        font='arial.ttf'                 # 字体 内置可选字体 arial.ttf calibri.ttf simsun.ttc
    )

    # 自定义验证码
    # vc.generate('abcd')

    # 数字验证码(默认5位)
    # vc.generate_digit()
    # 数字验证码(自定义位数)
    # vc.generate_digit(4)

    # 字母验证码(默认5位)
    # vc.generate_alpha()
    # 字母验证码(自定义位数)
    # vc.generate_alpha(5)

    # 数字字母混合验证码(默认5位)
    # vc.generate_mix()
    # 数字字母混合验证码(自定义位数)
    # vc.generate_mix(6)

    # 数字运算验证码(默认加法)
    vc.generate_op()
    # 数字运算验证码(加法)
    # vc.generate_op('+')
    # 数字运算验证码(减法)
    # vc.generate_op('-')
    # 数字运算验证码(乘法)
    # vc.generate_op('x')

    # 图片字节码
    # print(vc.get_img_bytes())
    # 图片base64编码
    print(vc.get_img_base64())
    # 保存图片
    vc.save()

Metadata

Release files for gvcode 1.0.3

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

Source distribution (sdist)

Source distribution for gvcode 1.0.3
File Size Uploaded
gvcode-1.0.3.tar.gz 10.8 MB Details

Built distribution (wheel)

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

Total release size: 21.7 MB

Release files / gvcode-1.0.3.tar.gz

Download URL gvcode-1.0.3.tar.gz
Size 10.8 MB
Tags Source
SHA-256 checksum
How to use checksums
62d87e08c766071ec2c6be86d82bf35fee7965b082f05054cf320dab21252830
BLAKE2b-256 checksum
How to use checksums
bae9a8d71deb1d88f19b8c04caab88ceff129f4e57c2afcfd669842415e9d6db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0

Release files / gvcode-1.0.3-py3-none-any.whl

Download URL gvcode-1.0.3-py3-none-any.whl
Size 10.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1a92668114c2dc5cedd34ae7381c3c19b53b09938ea9bc358a16b6ebcf4c3766
BLAKE2b-256 checksum
How to use checksums
78ecf935eb2de4a9b6eb990c95311b8ce8b4898f35e3e2fedaca12e3e57c3e6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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