From d3fd15d76b2e0be55c6fe454875a1114aa8a3f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=9E=9A?= Date: Fri, 29 Jul 2016 12:45:58 +0800 Subject: [PATCH] fix memory leak bug (#13) * fixed memory leak bug * fix memory leak bug --- captcha/image.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/captcha/image.py b/captcha/image.py index 3741c02..3a5c80f 100644 --- a/captcha/image.py +++ b/captcha/image.py @@ -30,6 +30,10 @@ else: __all__ = ['ImageCaptcha'] +table = [] +for i in range( 256 ): + table.append( i * 1.97 ) + class _Captcha(object): def generate(self, chars, format='png'): """Generate an Image Captcha of the given characters. @@ -202,7 +206,7 @@ class ImageCaptcha(_Captcha): for im in images: w, h = im.size - mask = im.convert('L').point(lambda i: i * 1.97) + mask = im.convert('L').point(table) image.paste(im, (offset, int((self._height - h) / 2)), mask) offset = offset + w + random.randint(-rand, 0)