cutechicken commited on
Commit
c1aae04
ยท
verified ยท
1 Parent(s): 4001c00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
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
- with open(svg_path, "r", encoding='utf-8') as f:
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, preview_html = convert_svg_to_ai(svg_path)
140
  outputs.append(ai_path)
141
- ai_preview = preview_html
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)