From ce59dedfe9e32eef55cac25f6371b8bb51ee110f Mon Sep 17 00:00:00 2001 From: eromoe Date: Wed, 21 Jun 2017 16:38:19 +0800 Subject: [PATCH] make width fixed (#17) --- captcha/image.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/captcha/image.py b/captcha/image.py index 3a5c80f..90496d9 100644 --- a/captcha/image.py +++ b/captcha/image.py @@ -210,6 +210,9 @@ class ImageCaptcha(_Captcha): image.paste(im, (offset, int((self._height - h) / 2)), mask) offset = offset + w + random.randint(-rand, 0) + if width > self._width: + image = image.resize((self._width, self._height)) + return image def generate_image(self, chars):