Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,8 @@ from PIL import Image
|
|
| 4 |
import time
|
| 5 |
|
| 6 |
def generate_upi_qr_sticker(VPA, Amount, VPN=None):
|
| 7 |
-
if not
|
| 8 |
-
|
| 9 |
|
| 10 |
# Generate UPI QR code
|
| 11 |
qr = qrcode.QRCode(version=1, box_size=10, border=5)
|
|
@@ -15,17 +15,12 @@ def generate_upi_qr_sticker(VPA, Amount, VPN=None):
|
|
| 15 |
qr.make(fit=True)
|
| 16 |
qr_image = qr.make_image(fill="black", back_color="white").convert("RGB")
|
| 17 |
|
| 18 |
-
|
| 19 |
-
template = Image.open('temp.png').convert("RGB")
|
| 20 |
-
|
| 21 |
# Resize the QR code if needed
|
| 22 |
-
qr_image = qr_image.resize((
|
| 23 |
-
|
| 24 |
-
# Paste the QR code onto your template
|
| 25 |
-
template.paste(qr_image, (225, 450))
|
| 26 |
|
| 27 |
# Return the final image
|
| 28 |
-
return
|
| 29 |
|
| 30 |
iface = gr.Interface(
|
| 31 |
fn=generate_upi_qr_sticker,
|
|
@@ -33,6 +28,8 @@ iface = gr.Interface(
|
|
| 33 |
outputs="image",
|
| 34 |
title="Dynamic UPI Payment QR Code",
|
| 35 |
description="A Dynamic UPI QR code sticker image is generated by entering the Virtual Payment Address (VPA), Virtual Private Name/ UPI Id (VPN), and payment amount. The system then creates a QR code that changes with each transaction, allowing users to scan it with a UPI-enabled app to make payments of the specified fixed amount effortlessly."
|
|
|
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
if __name__ == "__main__":
|
|
|
|
| 4 |
import time
|
| 5 |
|
| 6 |
def generate_upi_qr_sticker(VPA, Amount, VPN=None):
|
| 7 |
+
if not VPN is None:
|
| 8 |
+
VPN = VPA.split('@')[0]
|
| 9 |
|
| 10 |
# Generate UPI QR code
|
| 11 |
qr = qrcode.QRCode(version=1, box_size=10, border=5)
|
|
|
|
| 15 |
qr.make(fit=True)
|
| 16 |
qr_image = qr.make_image(fill="black", back_color="white").convert("RGB")
|
| 17 |
|
| 18 |
+
|
|
|
|
|
|
|
| 19 |
# Resize the QR code if needed
|
| 20 |
+
qr_image = qr_image.resize((500, 500))
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Return the final image
|
| 23 |
+
return qr_image
|
| 24 |
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=generate_upi_qr_sticker,
|
|
|
|
| 28 |
outputs="image",
|
| 29 |
title="Dynamic UPI Payment QR Code",
|
| 30 |
description="A Dynamic UPI QR code sticker image is generated by entering the Virtual Payment Address (VPA), Virtual Private Name/ UPI Id (VPN), and payment amount. The system then creates a QR code that changes with each transaction, allowing users to scan it with a UPI-enabled app to make payments of the specified fixed amount effortlessly."
|
| 31 |
+
|
| 32 |
+
|
| 33 |
)
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|