google-code-export / django-simple-captcha

Automatically exported from code.google.com/p/django-simple-captcha
MIT License
0 stars 0 forks source link

make image format configurable #52

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In version (0,3,0) in captcha\views.py, the image format is hard coded:

    out = StringIO()
    image.save(out, "PNG")
    out.seek(0)

    response = HttpResponse()
    response['Content-Type'] = "image/png"
    response.write(out.read())

Instead, I added this to captcha\conf\settings.py
    CAPTCHA_IMAGE_FORMAT = getattr(settings, 'CAPTCHA_IMAGE_FORMAT', 'PNG')
    CAPTCHA_IMAGE_CONTENT_TYPE = getattr(settings, 'CAPTCHA_IMAGE_CONTENT_TYPE', 'image/png')

and changed captcha\views.py to say:

    out = StringIO()
    image.save(out,settings.CAPTCHA_IMAGE_FORMAT)
    out.seek(0)

    response = HttpResponse()
    response['Content-Type'] = settings.CAPTCHA_IMAGE_CONTENT_TYPE
    response.write(out.read())

Original issue reported on code.google.com by KOstrom%...@gtempaccount.com on 27 Jul 2011 at 7:18

GoogleCodeExporter commented 9 years ago
Thanks, but why bother, what's wrong with PNG?

Original comment by mbonetti on 27 Jul 2011 at 7:27