MK-316 commited on
Commit
0593297
1 Parent(s): a349fa6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
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
- text_width, text_height = draw.textsize(title, font=font)
 
 
 
 
 
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