Django简单验证码图片大小 [英] Django Simple Captcha image size
问题描述
如何更改图像中的验证码图像大小和文本填充?
How can I change captcha image size and text padding in image?
我阅读官方文档,没有发现任何这些。
I read official docs and havn't found any of those.
推荐答案
我从来没有使用这个程序,但是我在代码中发现了一些:
I have never used this app, but I've found in code something:
#captcha/views.py
def captcha_image(request, key, scale=1):
#function goes here
所以,如果您使用附加参数 scale
调用captch_image,则可以更改大小。
如果您使用此应用程序的URL,如
So if you call captch_image with additional paramater scale
, you can change the size.
If you use urls for this app like
urlpatterns = patterns('captcha.views',
url(r'image/(?P<key>\w+)/$', 'captcha_image', name='captcha-image', kwargs={'scale': 1}),
您可以在行中更改 scale
参数。
You can change scale
parameter right in the line.
如果要更改维度的比例,我认为不支持,因为
If you want to change proportions of dimensions, I think it is not supported, because
#captcha/views.captcha_image
...
size = font.getsize(text)
size = (size[0] * 2, int(size[1] * 1.2))
...
它们在功能 captcha_image
,但可以替换字体。
They are hardcoded in the function captcha_image
. But you can replace the font.
这篇关于Django简单验证码图片大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!