问题
How can I change captcha image size and text padding in image?
I read official docs and havn't found any of those.
回答1:
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
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}),
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))
...
They are hardcoded in the function captcha_image
. But you can replace the font.
回答2:
Maybe it would be an option to resize the captcha in your css (e.g. setting width/heigth to 150%)
来源:https://stackoverflow.com/questions/18849981/django-simple-captcha-image-size