Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
import vtracer
|
3 |
import os
|
4 |
|
5 |
-
def create_preview_html(svg_path):
|
6 |
"""SVG를 HTML 미리보기로 변환"""
|
7 |
try:
|
8 |
with open(svg_path, 'r', encoding='utf-8') as f:
|
@@ -11,7 +11,9 @@ def create_preview_html(svg_path):
|
|
11 |
preview_html = f'''
|
12 |
<div style="width:100%; height:100%; background-color: white; padding: 20px; max-width: 800px; margin: 0 auto;">
|
13 |
<div style="width:100%; max-height:600px; overflow:auto;">
|
14 |
-
|
|
|
|
|
15 |
</div>
|
16 |
</div>
|
17 |
'''
|
@@ -20,7 +22,7 @@ def create_preview_html(svg_path):
|
|
20 |
print(f"미리보기 생성 실패: {str(e)}")
|
21 |
return None
|
22 |
|
23 |
-
def convert_svg_to_ai(svg_path):
|
24 |
"""SVG를 AI 파일로 변환"""
|
25 |
ai_path = svg_path.replace('.svg', '.ai')
|
26 |
|
@@ -28,6 +30,8 @@ def convert_svg_to_ai(svg_path):
|
|
28 |
with open(svg_path, 'r') as svg_file:
|
29 |
svg_content = svg_file.read()
|
30 |
|
|
|
|
|
31 |
# AI 파일 헤더
|
32 |
ai_header = """%!PS-Adobe-3.0
|
33 |
%%Creator: Adobe Illustrator(TM) SVG Converter
|
@@ -64,11 +68,16 @@ def convert_svg_to_ai(svg_path):
|
|
64 |
ai_file.write("\n%%EndDocument\n")
|
65 |
ai_file.write("\n%%Trailer\n%%EOF\n")
|
66 |
|
|
|
|
|
|
|
|
|
67 |
# HTML 미리보기 생성
|
68 |
-
preview_html = create_preview_html(svg_path)
|
69 |
|
70 |
return ai_path, preview_html
|
71 |
|
|
|
72 |
def convert_to_vector(
|
73 |
image,
|
74 |
save_svg,
|
|
|
2 |
import vtracer
|
3 |
import os
|
4 |
|
5 |
+
def create_preview_html(svg_path, image_width, image_height):
|
6 |
"""SVG를 HTML 미리보기로 변환"""
|
7 |
try:
|
8 |
with open(svg_path, 'r', encoding='utf-8') as f:
|
|
|
11 |
preview_html = f'''
|
12 |
<div style="width:100%; height:100%; background-color: white; padding: 20px; max-width: 800px; margin: 0 auto;">
|
13 |
<div style="width:100%; max-height:600px; overflow:auto;">
|
14 |
+
<svg style="width:100%; height:auto;" viewBox="0 0 {image_width} {image_height}">
|
15 |
+
{svg_content[svg_content.find('>')+1:]}
|
16 |
+
</svg>
|
17 |
</div>
|
18 |
</div>
|
19 |
'''
|
|
|
22 |
print(f"미리보기 생성 실패: {str(e)}")
|
23 |
return None
|
24 |
|
25 |
+
def convert_svg_to_ai(svg_path, image_width, image_height):
|
26 |
"""SVG를 AI 파일로 변환"""
|
27 |
ai_path = svg_path.replace('.svg', '.ai')
|
28 |
|
|
|
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 |
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,
|