mirror of https://github.com/tp4a/teleport
temp.
parent
09176d78f9
commit
63b0ad026a
|
@ -67,36 +67,41 @@ def async_enc(data):
|
||||||
return {'code': 0, 'data': return_data['data']['c']}
|
return {'code': 0, 'data': return_data['data']['c']}
|
||||||
|
|
||||||
|
|
||||||
_chars = 'ACDEFHJKLMNPQRTVWXY34679'
|
_chars = 'AaCDdEeFfHJjKkLMmNnPpQRrTtVvWwXxYy34679'
|
||||||
|
_font_dir = os.path.join(cfg.res_path, 'fonts')
|
||||||
|
|
||||||
|
|
||||||
def gen_captcha():
|
def gen_captcha():
|
||||||
_font_dir = os.path.join(cfg.res_path, 'fonts')
|
|
||||||
captcha_image_t = captcha(
|
captcha_image_t = captcha(
|
||||||
width=136,
|
width=136,
|
||||||
height=36,
|
height=36,
|
||||||
drawings=[
|
drawings=[
|
||||||
background(color='#eeeeee'),
|
background(color='#eeeeee'),
|
||||||
|
# curve(color='#4388d5', width=1, number=10),
|
||||||
|
curve(color='#4388d5', width=1, number=10),
|
||||||
|
curve(color='#af6fff', width=3, number=16),
|
||||||
|
noise(number=80, color='#eeeeee', level=3),
|
||||||
text(fonts=[
|
text(fonts=[
|
||||||
os.path.join(_font_dir, '001.ttf')
|
os.path.join(_font_dir, '001.ttf')
|
||||||
],
|
],
|
||||||
font_sizes=(28, 34, 36, 32),
|
# font_sizes=(28, 34, 36, 32),
|
||||||
|
font_sizes=(34, 36, 32),
|
||||||
color='#63a8f5',
|
color='#63a8f5',
|
||||||
squeeze_factor=1.1,
|
squeeze_factor=1.2,
|
||||||
drawings=[
|
drawings=[
|
||||||
warp(dx_factor=0.05, dy_factor=0.05),
|
# warp(dx_factor=0.05, dy_factor=0.05),
|
||||||
rotate(angle=15),
|
rotate(angle=15),
|
||||||
offset()
|
offset()
|
||||||
]),
|
]),
|
||||||
curve(color='#af6fff', width=2, number=9),
|
# curve(color='#af6fff', width=3, number=16),
|
||||||
noise(),
|
noise(number=60, color='#eeeeee', level=2),
|
||||||
smooth()
|
smooth(),
|
||||||
])
|
])
|
||||||
|
|
||||||
chars_t = random.sample(_chars, 4)
|
chars_t = random.sample(_chars, 4)
|
||||||
image = captcha_image_t(chars_t)
|
image = captcha_image_t(chars_t)
|
||||||
|
|
||||||
out = io.BytesIO()
|
out = io.BytesIO()
|
||||||
image.save(out, "jpeg", quality=90)
|
image.save(out, "jpeg", quality=100)
|
||||||
# web.header('Content-Type','image/jpeg')
|
# web.header('Content-Type','image/jpeg')
|
||||||
return ''.join(chars_t), out.getvalue()
|
return ''.join(chars_t), out.getvalue()
|
||||||
|
|
Loading…
Reference in New Issue