Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,7 +79,10 @@ def process_image(image, text):
|
|
| 79 |
logging.warning(f"Error loading font. Using default. {e}")
|
| 80 |
font = ImageFont.load_default()
|
| 81 |
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
| 83 |
text_position = ((width - text_width) // 2, (height - text_height) // 2)
|
| 84 |
draw.text(text_position, text, fill=(0, 0, 0, 255), font=font)
|
| 85 |
|
|
|
|
| 79 |
logging.warning(f"Error loading font. Using default. {e}")
|
| 80 |
font = ImageFont.load_default()
|
| 81 |
|
| 82 |
+
bbox = draw.textbbox((0, 0), text, font=font)
|
| 83 |
+
text_width = bbox[2] - bbox[0]
|
| 84 |
+
text_height = bbox[3] - bbox[1]
|
| 85 |
+
|
| 86 |
text_position = ((width - text_width) // 2, (height - text_height) // 2)
|
| 87 |
draw.text(text_position, text, fill=(0, 0, 0, 255), font=font)
|
| 88 |
|