Spaces:
Running
Running
add buffer
Browse files- myapp/app.py +7 -7
myapp/app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import re
|
2 |
from functools import partial
|
3 |
-
from
|
4 |
-
from tempfile import NamedTemporaryFile
|
5 |
from typing import Any
|
6 |
|
7 |
import gradio as gr
|
@@ -63,20 +62,21 @@ with gr.Blocks() as demo:
|
|
63 |
|
64 |
return f"#{r:x}{g:x}{b:x}".upper()
|
65 |
|
|
|
66 |
qr_code = segno.make(data[text], error="h")
|
67 |
-
suffix = Path(data[background]).suffix
|
68 |
|
69 |
-
with
|
70 |
write_artistic(
|
71 |
qr_code,
|
72 |
-
target=
|
73 |
-
background=
|
|
|
74 |
scale=data[scale],
|
75 |
light=to_hex_format(data[color_light]),
|
76 |
dark=to_hex_format(data[color_dark]),
|
77 |
)
|
78 |
|
79 |
-
return Image.open(
|
80 |
|
81 |
gr.on(
|
82 |
[button.click, prompt.submit],
|
|
|
1 |
import re
|
2 |
from functools import partial
|
3 |
+
from io import BytesIO
|
|
|
4 |
from typing import Any
|
5 |
|
6 |
import gradio as gr
|
|
|
62 |
|
63 |
return f"#{r:x}{g:x}{b:x}".upper()
|
64 |
|
65 |
+
image = Image.open(data[background])
|
66 |
qr_code = segno.make(data[text], error="h")
|
|
|
67 |
|
68 |
+
with BytesIO() as buffer:
|
69 |
write_artistic(
|
70 |
qr_code,
|
71 |
+
target=buffer,
|
72 |
+
background=image.fp,
|
73 |
+
kind=image.format,
|
74 |
scale=data[scale],
|
75 |
light=to_hex_format(data[color_light]),
|
76 |
dark=to_hex_format(data[color_dark]),
|
77 |
)
|
78 |
|
79 |
+
return Image.open(buffer)
|
80 |
|
81 |
gr.on(
|
82 |
[button.click, prompt.submit],
|