Saarthak2002 commited on
Commit
0b1e3c3
·
verified ·
1 Parent(s): 6cb1c31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -58,10 +58,16 @@ def add_text_to_image(image, product_name, tagline, cta_text, font_size=50):
58
  """
59
  draw = ImageDraw.Draw(image)
60
 
61
- # Load font for product name, tagline, and CTA
62
- product_font = ImageFont.truetype("arial.ttf", font_size + 20) # Larger for product name
63
- tagline_font = ImageFont.truetype("arial.ttf", font_size) # Slightly smaller for tagline
64
- cta_font = ImageFont.truetype("arial.ttf", font_size - 10) # Smaller for CTA
 
 
 
 
 
 
65
 
66
  # Define positions for text
67
  product_name_position = (50, 50)
 
58
  """
59
  draw = ImageDraw.Draw(image)
60
 
61
+ try:
62
+ # Load font for product name, tagline, and CTA
63
+ product_font = ImageFont.truetype("arial.ttf", font_size + 20) # Larger for product name
64
+ tagline_font = ImageFont.truetype("arial.ttf", font_size) # Slightly smaller for tagline
65
+ cta_font = ImageFont.truetype("arial.ttf", font_size - 10) # Smaller for CTA
66
+ except IOError:
67
+ # Fallback font in case "arial.ttf" is not available
68
+ product_font = ImageFont.load_default()
69
+ tagline_font = ImageFont.load_default()
70
+ cta_font = ImageFont.load_default()
71
 
72
  # Define positions for text
73
  product_name_position = (50, 50)