Spaces:
Runtime error
Runtime error
File size: 534 Bytes
c907706 9f8a52c c907706 9f8a52c c907706 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
import qrcode
import io
def url_to_qr(url):
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
qr.add_data(url)
qr.make(fit=True)
qr_img = qr.make_image(fill_color="black", back_color="white")
# Convertir l'image en bytes
img_byte_arr = io.BytesIO()
qr_img.save(img_byte_arr, format='PNG')
img_byte_arr.seek(0)
return img_byte_arr
iface = gr.Interface(fn=url_to_qr, inputs="text", outputs="image")
iface.launch()
|