Commit
·
2c75d59
1
Parent(s):
40895e5
Update app.py
Browse files
app.py
CHANGED
@@ -52,9 +52,10 @@ def generate_caption(image):
|
|
52 |
y = 10
|
53 |
for line in text_lines:
|
54 |
line_width = draw.textlength(line, font=font)
|
55 |
-
|
|
|
56 |
x = (pil_image.width - line_width) // 2
|
57 |
-
|
58 |
draw.text((x, y), line, fill=(255, 255, 255), font=font)
|
59 |
y += line_height + int(line_height * 0.1)
|
60 |
|
|
|
52 |
y = 10
|
53 |
for line in text_lines:
|
54 |
line_width = draw.textlength(line, font=font)
|
55 |
+
line_mask = font.getmask(line)
|
56 |
+
_, line_height = line_mask.size
|
57 |
x = (pil_image.width - line_width) // 2
|
58 |
+
|
59 |
draw.text((x, y), line, fill=(255, 255, 255), font=font)
|
60 |
y += line_height + int(line_height * 0.1)
|
61 |
|