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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -39,7 +39,7 @@ def generate_caption(image):
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
@@ -50,12 +50,13 @@ def generate_caption(image):
50
  text_lines = wrapped_text
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
59
 
60
  pil_image = pil_image.convert('RGB')
61
 
 
39
  draw = ImageDraw.Draw(pil_image)
40
 
41
  # Determine font size
42
+ font_size = 80
43
  font = ImageFont.truetype("impact.ttf", font_size)
44
 
45
  # Calculate the width for text wrap
 
50
  text_lines = wrapped_text
51
 
52
  y = 10
53
+ line_spacing = 10 # Add extra spacing between lines
54
  for line in text_lines:
55
  line_width = draw.textlength(line, font=font)
56
  _, line_height = font.getmetrics()
57
  x = (pil_image.width - line_width) // 2
58
  draw.text((x, y), line, fill=(255, 255, 255), font=font)
59
+ y += line_height + line_spacing
60
 
61
  pil_image = pil_image.convert('RGB')
62