Adityadn commited on
Commit
0c98104
·
verified ·
1 Parent(s): af74360

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -17,20 +17,20 @@ def generate_qr_with_logo(data: str, logo_path: str):
17
  # Create an image for the QR code
18
  img_qr = qr.make_image(fill='black', back_color='white')
19
 
20
- # Open the logo image
21
- logo = Image.open(logo_path) # Provide logo path
22
- logo_size = 50 # Adjust size of the logo
23
- logo = logo.resize((logo_size, logo_size))
24
 
25
- # Get QR code dimensions
26
- qr_width, qr_height = img_qr.size
27
 
28
- # Calculate logo position to center it
29
- logo_x = (qr_width - logo_size) // 2
30
- logo_y = (qr_height - logo_size) // 2
31
 
32
- # Paste the logo onto the QR code
33
- img_qr.paste(logo, (logo_x, logo_y), logo)
34
 
35
  # Save and return the final QR code with logo
36
  output_path = "qr_with_logo.png"
@@ -39,8 +39,8 @@ def generate_qr_with_logo(data: str, logo_path: str):
39
  return output_path
40
 
41
  # Gradio Interface
42
- def qr_code_interface(data: str, logo_path: str):
43
- result = generate_qr_with_logo(data, logo_path)
44
  return result
45
 
46
  # Create a Gradio interface
@@ -48,7 +48,7 @@ interface = gr.Interface(
48
  fn=qr_code_interface,
49
  inputs=[
50
  gr.Textbox(label="Enter Data for QR Code", placeholder="Enter URL or text here..."),
51
- gr.File(label="Upload Logo", type="file") # File input for the logo
52
  ],
53
  outputs=gr.Image(type="file", label="Generated QR Code with Logo"),
54
  description="Generate a QR Code with your custom logo placed in the center. You can provide any text or URL as data and upload an image to be used as the logo.",
 
17
  # Create an image for the QR code
18
  img_qr = qr.make_image(fill='black', back_color='white')
19
 
20
+ # # Open the logo image
21
+ # logo = Image.open(logo_path) # Provide logo path
22
+ # logo_size = 50 # Adjust size of the logo
23
+ # logo = logo.resize((logo_size, logo_size))
24
 
25
+ # # Get QR code dimensions
26
+ # qr_width, qr_height = img_qr.size
27
 
28
+ # # Calculate logo position to center it
29
+ # logo_x = (qr_width - logo_size) // 2
30
+ # logo_y = (qr_height - logo_size) // 2
31
 
32
+ # # Paste the logo onto the QR code
33
+ # img_qr.paste(logo, (logo_x, logo_y), logo)
34
 
35
  # Save and return the final QR code with logo
36
  output_path = "qr_with_logo.png"
 
39
  return output_path
40
 
41
  # Gradio Interface
42
+ def qr_code_interface(data: str):
43
+ result = generate_qr_with_logo(data)
44
  return result
45
 
46
  # Create a Gradio interface
 
48
  fn=qr_code_interface,
49
  inputs=[
50
  gr.Textbox(label="Enter Data for QR Code", placeholder="Enter URL or text here..."),
51
+ # gr.File(label="Upload Logo", type="file") # File input for the logo
52
  ],
53
  outputs=gr.Image(type="file", label="Generated QR Code with Logo"),
54
  description="Generate a QR Code with your custom logo placed in the center. You can provide any text or URL as data and upload an image to be used as the logo.",