fix memory leak bug (#13)

* fixed memory leak bug

* fix memory leak bug
This commit is contained in:
张垚
2016-07-29 12:45:58 +08:00
committed by Hsiaoming Yang
parent 5bf0eadb47
commit d3fd15d76b

View File

@@ -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)