Spaces:
Build error
Build error
another way to download svg file.
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ Refer to https://huggingface.co/spaces/dt/ascii-art/blob/main/app.py
|
|
5 |
import sys, random, argparse
|
6 |
import numpy as np
|
7 |
import math
|
|
|
8 |
from PIL import Image, ImageFont, ImageDraw
|
9 |
import gradio as gr
|
10 |
|
@@ -184,15 +185,18 @@ def sepia(input_img):
|
|
184 |
|
185 |
my_image, my_colors = colorizeTextImage(input_img, my_image)
|
186 |
my_html = convertTextToHTML(my_colors, aimg)
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
189 |
|
190 |
-
return [my_image,
|
191 |
|
192 |
|
193 |
iface = gr.Interface(sepia,
|
194 |
gr.inputs.Image(),
|
195 |
-
["image", "
|
196 |
title = "Colorful ASCII Art",
|
197 |
description = "Convert an image to colorful ASCII art based on ascii character density. Copy and paste the text to a notepad to see it correctly")
|
198 |
|
|
|
5 |
import sys, random, argparse
|
6 |
import numpy as np
|
7 |
import math
|
8 |
+
import base64
|
9 |
from PIL import Image, ImageFont, ImageDraw
|
10 |
import gradio as gr
|
11 |
|
|
|
185 |
|
186 |
my_image, my_colors = colorizeTextImage(input_img, my_image)
|
187 |
my_html = convertTextToHTML(my_colors, aimg)
|
188 |
+
encodedBytes = base64.b64encode(my_html.encode("utf-8"))
|
189 |
+
encodedStr = str(encodedBytes, "utf-8")
|
190 |
+
my_file_download = r'''
|
191 |
+
<a href="data:image/svg+xml;base64,%s" download="result.svg">Click to download result.svg</a>.
|
192 |
+
''' % encodedStr
|
193 |
|
194 |
+
return [my_image, my_file_download, my_html]
|
195 |
|
196 |
|
197 |
iface = gr.Interface(sepia,
|
198 |
gr.inputs.Image(),
|
199 |
+
["image", "html", "html"],
|
200 |
title = "Colorful ASCII Art",
|
201 |
description = "Convert an image to colorful ASCII art based on ascii character density. Copy and paste the text to a notepad to see it correctly")
|
202 |
|