From 6cb50b9c0cd3b38a0235398a37f65fa823878496 Mon Sep 17 00:00:00 2001 From: zming <517046497@qq.com> Date: Thu, 13 Jul 2017 12:54:00 +0800 Subject: [PATCH] [captcha] fixed size --- thirdpart/captcha/conf/settings.py | 1 + thirdpart/captcha/views.py | 1 + 2 files changed, 2 insertions(+) diff --git a/thirdpart/captcha/conf/settings.py b/thirdpart/captcha/conf/settings.py index e344bd9107..a57684b1f0 100644 --- a/thirdpart/captcha/conf/settings.py +++ b/thirdpart/captcha/conf/settings.py @@ -1,6 +1,7 @@ import os from django.conf import settings +CAPTCHA_IMAGE_SIZE = getattr(settings, 'CAPTCHA_IMAGE_SIZE', (90,42)) CAPTCHA_FONT_PATH = getattr(settings, 'CAPTCHA_FONT_PATH', os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'fonts/Vera.ttf'))) CAPTCHA_FONT_SIZE = getattr(settings, 'CAPTCHA_FONT_SIZE', 22) CAPTCHA_LETTER_ROTATION = getattr(settings, 'CAPTCHA_LETTER_ROTATION', (-35, 35)) diff --git a/thirdpart/captcha/views.py b/thirdpart/captcha/views.py index 3b096f2d4a..bb9443293b 100644 --- a/thirdpart/captcha/views.py +++ b/thirdpart/captcha/views.py @@ -92,6 +92,7 @@ def captcha_image(request, key, scale=1): for f in settings.filter_functions(): image = f(image) + image = image.resize(settings.CAPTCHA_IMAGE_SIZE, Image.ANTIALIAS) out = StringIO() image.save(out, "PNG") out.seek(0)