Upload anytext.py
Browse files- anytext.py +1 -2
anytext.py
CHANGED
|
@@ -725,11 +725,10 @@ class TextEmbeddingModule(nn.Module):
|
|
| 725 |
new_font = font.font_variant(size=int(g_size * ratio))
|
| 726 |
|
| 727 |
left, top, right, bottom = new_font.getbbox(text)
|
| 728 |
-
offset_x, offset_y = new_font.getoffset(text)
|
| 729 |
text_width = right - left
|
| 730 |
text_height = bottom - top
|
| 731 |
x = (img.width - text_width) // 2
|
| 732 |
-
y = (img.height - text_height) // 2 -
|
| 733 |
draw.text((x, y), text, font=new_font, fill="white")
|
| 734 |
img = np.expand_dims(np.array(img), axis=2).astype(np.float64)
|
| 735 |
return img
|
|
|
|
| 725 |
new_font = font.font_variant(size=int(g_size * ratio))
|
| 726 |
|
| 727 |
left, top, right, bottom = new_font.getbbox(text)
|
|
|
|
| 728 |
text_width = right - left
|
| 729 |
text_height = bottom - top
|
| 730 |
x = (img.width - text_width) // 2
|
| 731 |
+
y = (img.height - text_height) // 2 - top // 2
|
| 732 |
draw.text((x, y), text, font=new_font, fill="white")
|
| 733 |
img = np.expand_dims(np.array(img), axis=2).astype(np.float64)
|
| 734 |
return img
|