mirror of
https://github.com/lepture/captcha.git
synced 2026-03-13 09:43:22 +08:00
fix: use multiline_textbbox for image captcha
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,5 +18,6 @@ cover/
|
||||
*.so
|
||||
venv/
|
||||
.venv/
|
||||
demo.*
|
||||
.coverage
|
||||
coverage.xml
|
||||
|
||||
@@ -103,10 +103,7 @@ class ImageCaptcha:
|
||||
draw: ImageDraw,
|
||||
color: ColorTuple) -> Image:
|
||||
font = random.choice(self.truefonts)
|
||||
|
||||
left, top, right, bottom = draw.textbbox((0, 0), c, font=font)
|
||||
w = int((right - left)*1.7) or 1
|
||||
h = int((bottom - top)*1.7) or 1
|
||||
_, _, w, h = draw.multiline_textbbox((1, 1), c, font=font)
|
||||
|
||||
dx1 = random.randint(0, 4)
|
||||
dy1 = random.randint(0, 6)
|
||||
|
||||
Reference in New Issue
Block a user