Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,12 @@ def generate_qr_code(url, title):
|
|
28 |
draw = ImageDraw.Draw(result_image)
|
29 |
font_path = "dejavu-sans-bold.ttf" # Ensure the font path is correct
|
30 |
font = ImageFont.truetype(font_path, 24) # Use a specific font size
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
text_x = (image_width - text_width) / 2 # Center the text
|
33 |
draw.text((text_x, 20), title, fill="black", font=font)
|
34 |
|
|
|
28 |
draw = ImageDraw.Draw(result_image)
|
29 |
font_path = "dejavu-sans-bold.ttf" # Ensure the font path is correct
|
30 |
font = ImageFont.truetype(font_path, 24) # Use a specific font size
|
31 |
+
|
32 |
+
# Get the size of the text using textbbox
|
33 |
+
text_bbox = draw.textbbox((0, 0), title, font=font)
|
34 |
+
text_width = text_bbox[2] - text_bbox[0]
|
35 |
+
text_height = text_bbox[3] - text_bbox[1]
|
36 |
+
|
37 |
text_x = (image_width - text_width) / 2 # Center the text
|
38 |
draw.text((text_x, 20), title, fill="black", font=font)
|
39 |
|