Skip to content
Advertisement

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.

Advertisement

Answer

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.

Advertisement