3morrrrr commited on
Commit
a845d2b
·
verified ·
1 Parent(s): b0a556f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
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
- text_width, text_height = draw.textsize(text, font=font)
 
 
 
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