Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,13 +17,17 @@ setup_avif_decode()
|
|
17 |
|
18 |
|
19 |
def convert_avif_to_png(avif_file):
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
|
29 |
css = """
|
@@ -46,7 +50,6 @@ with gr.Blocks(css=css) as demo:
|
|
46 |
)
|
47 |
run_button = gr.Button("Convert", scale=0)
|
48 |
result = gr.Gallery(label="Result")
|
49 |
-
|
50 |
run_button.click(
|
51 |
fn=convert_avif_to_png,
|
52 |
inputs=[avif_file],
|
|
|
17 |
|
18 |
|
19 |
def convert_avif_to_png(avif_file):
|
20 |
+
def convert_avif_to_png(avif_files):
|
21 |
+
output_paths = []
|
22 |
+
for avif_file in avif_files:
|
23 |
+
avif_path = avif_file.name
|
24 |
+
png_path = avif_path.rsplit('.', 1)[0] + '.png'
|
25 |
+
result = subprocess.run(["avif-decode/target/release/avif_decode", "-f", avif_path, png_path], capture_output=True, text=True)
|
26 |
+
if result.returncode == 0:
|
27 |
+
output_paths.append(png_path)
|
28 |
+
else:
|
29 |
+
output_paths.append(f"Error converting {avif_file.name}: {result.stderr}")
|
30 |
+
return output_paths
|
31 |
|
32 |
|
33 |
css = """
|
|
|
50 |
)
|
51 |
run_button = gr.Button("Convert", scale=0)
|
52 |
result = gr.Gallery(label="Result")
|
|
|
53 |
run_button.click(
|
54 |
fn=convert_avif_to_png,
|
55 |
inputs=[avif_file],
|