andreinigo commited on
Commit
2d292a8
·
1 Parent(s): 0ef34b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -39,8 +39,7 @@ def generate_caption(image):
39
  draw = ImageDraw.Draw(pil_image)
40
 
41
  # Determine font size
42
- max_width = int(pil_image.width * 0.9)
43
- font_size = 60
44
  font = ImageFont.truetype("impact.ttf", font_size)
45
 
46
  # Calculate the width for text wrap
@@ -52,7 +51,8 @@ def generate_caption(image):
52
 
53
  y = 10
54
  for line in text_lines:
55
- line_width, line_height = draw.textsize(line, font=font)
 
56
  x = (pil_image.width - line_width) // 2
57
  draw.text((x, y), line, fill=(255, 255, 255), font=font)
58
  y += line_height
 
39
  draw = ImageDraw.Draw(pil_image)
40
 
41
  # Determine font size
42
+ font_size = 66
 
43
  font = ImageFont.truetype("impact.ttf", font_size)
44
 
45
  # Calculate the width for text wrap
 
51
 
52
  y = 10
53
  for line in text_lines:
54
+ line_width = draw.textlength(line, font=font)
55
+ _, line_height = font.getmetrics()
56
  x = (pil_image.width - line_width) // 2
57
  draw.text((x, y), line, fill=(255, 255, 255), font=font)
58
  y += line_height