Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,6 @@ def convert_svg_to_ai(svg_path, image_width, image_height):
|
|
30 |
with open(svg_path, 'r') as svg_file:
|
31 |
svg_content = svg_file.read()
|
32 |
|
33 |
-
|
34 |
-
|
35 |
# AI ํ์ผ ํค๋
|
36 |
ai_header = """%!PS-Adobe-3.0
|
37 |
%%Creator: Adobe Illustrator(TM) SVG Converter
|
@@ -68,16 +66,11 @@ def convert_svg_to_ai(svg_path, image_width, image_height):
|
|
68 |
ai_file.write("\n%%EndDocument\n")
|
69 |
ai_file.write("\n%%Trailer\n%%EOF\n")
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
# AI ํ์ผ ํค๋ ์์ฑ ๋ฐ ํ์ผ ๋ณํ ๋ก์ง (์ด์ ๊ณผ ๋์ผ)
|
74 |
-
|
75 |
# HTML ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ฑ
|
76 |
preview_html = create_preview_html(svg_path, image_width, image_height)
|
77 |
|
78 |
return ai_path, preview_html
|
79 |
|
80 |
-
|
81 |
def convert_to_vector(
|
82 |
image,
|
83 |
save_svg,
|
@@ -129,16 +122,14 @@ def convert_to_vector(
|
|
129 |
|
130 |
# SVG ํ์ผ ์ฒ๋ฆฌ
|
131 |
if save_svg:
|
132 |
-
|
133 |
-
svg_content = f.read()
|
134 |
-
preview = gr.HTML(f'<svg viewBox="0 0 {image.width} {image.height}">{svg_content}</svg>')
|
135 |
outputs.append(svg_path)
|
136 |
|
137 |
# AI ํ์ผ ์ฒ๋ฆฌ
|
138 |
if save_ai:
|
139 |
-
ai_path,
|
140 |
outputs.append(ai_path)
|
141 |
-
ai_preview =
|
142 |
|
143 |
if not save_svg: # SVG๊ฐ ์ ํ๋์ง ์์๋ค๋ฉด ์์ ํ์ผ ์ญ์
|
144 |
os.remove(svg_path)
|
|
|
30 |
with open(svg_path, 'r') as svg_file:
|
31 |
svg_content = svg_file.read()
|
32 |
|
|
|
|
|
33 |
# AI ํ์ผ ํค๋
|
34 |
ai_header = """%!PS-Adobe-3.0
|
35 |
%%Creator: Adobe Illustrator(TM) SVG Converter
|
|
|
66 |
ai_file.write("\n%%EndDocument\n")
|
67 |
ai_file.write("\n%%Trailer\n%%EOF\n")
|
68 |
|
|
|
|
|
|
|
|
|
69 |
# HTML ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ฑ
|
70 |
preview_html = create_preview_html(svg_path, image_width, image_height)
|
71 |
|
72 |
return ai_path, preview_html
|
73 |
|
|
|
74 |
def convert_to_vector(
|
75 |
image,
|
76 |
save_svg,
|
|
|
122 |
|
123 |
# SVG ํ์ผ ์ฒ๋ฆฌ
|
124 |
if save_svg:
|
125 |
+
preview = gr.HTML(create_preview_html(svg_path, image.width, image.height))
|
|
|
|
|
126 |
outputs.append(svg_path)
|
127 |
|
128 |
# AI ํ์ผ ์ฒ๋ฆฌ
|
129 |
if save_ai:
|
130 |
+
ai_path, ai_preview_html = convert_svg_to_ai(svg_path, image.width, image.height)
|
131 |
outputs.append(ai_path)
|
132 |
+
ai_preview = gr.HTML(ai_preview_html)
|
133 |
|
134 |
if not save_svg: # SVG๊ฐ ์ ํ๋์ง ์์๋ค๋ฉด ์์ ํ์ผ ์ญ์
|
135 |
os.remove(svg_path)
|