Update app.py
Browse files
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 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|