dschandra commited on
Commit
fb10459
·
verified ·
1 Parent(s): cac4307

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -23,7 +23,10 @@ def generate_image(text_description):
23
  # Draw each line of text
24
  y_text = 20
25
  for line in lines:
26
- line_width, line_height = draw.textsize(line, font=font)
 
 
 
27
  draw.text((20, y_text), line, font=font, fill=(255, 255, 255))
28
  y_text += line_height + 5 # Add spacing between lines
29
 
 
23
  # Draw each line of text
24
  y_text = 20
25
  for line in lines:
26
+ # Use textbbox to get the bounding box of the text
27
+ bbox = draw.textbbox((0, 0), line, font=font)
28
+ line_width = bbox[2] - bbox[0] # right - left
29
+ line_height = bbox[3] - bbox[1] # bottom - top
30
  draw.text((20, y_text), line, font=font, fill=(255, 255, 255))
31
  y_text += line_height + 5 # Add spacing between lines
32