andreinigo commited on
Commit
40895e5
·
1 Parent(s): a66e64b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -38,8 +38,8 @@ def generate_caption(image):
38
  # Put the meme text on the image
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,13 +50,13 @@ def generate_caption(image):
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
 
 
38
  # Put the meme text on the image
39
  draw = ImageDraw.Draw(pil_image)
40
 
41
+ # Set the fixed font size to 80
42
+ font_size = 60
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
  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
+
58
  draw.text((x, y), line, fill=(255, 255, 255), font=font)
59
+ y += line_height + int(line_height * 0.1)
60
 
61
  pil_image = pil_image.convert('RGB')
62