codelion commited on
Commit
ee6a1c6
·
verified ·
1 Parent(s): a8aa56e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,10 +3,10 @@ import gradio as gr
3
  from PIL import Image
4
  import os
5
 
6
- def show(svg_input):
7
- # Convert SVG to PNG
8
  output_path = "./test.png"
9
- cairosvg.svg2png(bytestring=svg_input.encode('utf-8'), write_to=output_path)
10
 
11
  # Open and return the PNG image
12
  png_image = Image.open(output_path)
@@ -17,7 +17,7 @@ with gr.Blocks() as bl:
17
 
18
  with gr.Row():
19
  with gr.Column():
20
- svg_input = gr.Textbox(label="SVG URL or Code", placeholder="Enter SVG URL or paste SVG code here")
21
  convert_btn = gr.Button("Convert")
22
 
23
  with gr.Column():
 
3
  from PIL import Image
4
  import os
5
 
6
+ def show(svg_file):
7
+ # Convert uploaded SVG file to PNG
8
  output_path = "./test.png"
9
+ cairosvg.svg2png(file_obj=svg_file, write_to=output_path)
10
 
11
  # Open and return the PNG image
12
  png_image = Image.open(output_path)
 
17
 
18
  with gr.Row():
19
  with gr.Column():
20
+ svg_input = gr.File(label="Upload SVG File", file_types=[".svg"])
21
  convert_btn = gr.Button("Convert")
22
 
23
  with gr.Column():