Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -35,10 +35,10 @@ def optimize_image(image):
|
|
35 |
webp_lossy_diff = original_size - webp_lossy_size
|
36 |
|
37 |
return [
|
38 |
-
lossless_img, f"Sin pérdida: {lossless_size:.2f} KB (
|
39 |
-
lossy_img, f"Con pérdida: {lossy_size:.2f} KB (
|
40 |
-
reduced_img, f"Reducción de resolución: {reduced_size:.2f} KB (
|
41 |
-
webp_lossy_img, f"WebP con pérdida: {webp_lossy_size:.2f} KB (
|
42 |
]
|
43 |
|
44 |
with gr.Blocks() as demo:
|
@@ -48,27 +48,40 @@ with gr.Blocks() as demo:
|
|
48 |
optimize_button = gr.Button("Optimizar")
|
49 |
|
50 |
with gr.Row():
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
|
|
|
|
56 |
|
57 |
-
|
58 |
-
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
|
63 |
optimize_button.click(
|
64 |
fn=optimize_image,
|
65 |
inputs=image_input,
|
66 |
outputs=[
|
67 |
-
optimized_output1, optimized_size1,
|
68 |
-
optimized_output2, optimized_size2,
|
69 |
-
optimized_output3, optimized_size3,
|
70 |
-
optimized_output4, optimized_size4
|
71 |
]
|
72 |
)
|
73 |
|
|
|
|
|
|
|
|
|
|
|
74 |
demo.launch()
|
|
|
35 |
webp_lossy_diff = original_size - webp_lossy_size
|
36 |
|
37 |
return [
|
38 |
+
lossless_img, f"Sin pérdida: {lossless_size:.2f} KB ({-lossless_diff:.2f} KB)", lossless_output_path,
|
39 |
+
lossy_img, f"Con pérdida: {lossy_size:.2f} KB ({-lossy_diff:.2f} KB)", lossy_output_path,
|
40 |
+
reduced_img, f"Reducción de resolución: {reduced_size:.2f} KB ({-reduced_diff:.2f} KB)", reduced_output_path,
|
41 |
+
webp_lossy_img, f"WebP con pérdida: {webp_lossy_size:.2f} KB ({-webp_lossy_diff:.2f} KB)", webp_lossy_output_path
|
42 |
]
|
43 |
|
44 |
with gr.Blocks() as demo:
|
|
|
48 |
optimize_button = gr.Button("Optimizar")
|
49 |
|
50 |
with gr.Row():
|
51 |
+
with gr.Column():
|
52 |
+
optimized_output1 = gr.Image(label="Optimización sin pérdida")
|
53 |
+
optimized_size1 = gr.Text(visible=False)
|
54 |
+
download_button1 = gr.Button("Descargar")
|
55 |
|
56 |
+
with gr.Column():
|
57 |
+
optimized_output2 = gr.Image(label="Optimización con pérdida")
|
58 |
+
optimized_size2 = gr.Text(visible=False)
|
59 |
+
download_button2 = gr.Button("Descargar")
|
60 |
|
61 |
+
with gr.Column():
|
62 |
+
optimized_output3 = gr.Image(label="Reducción de resolución")
|
63 |
+
optimized_size3 = gr.Text(visible=False)
|
64 |
+
download_button3 = gr.Button("Descargar")
|
65 |
|
66 |
+
with gr.Column():
|
67 |
+
optimized_output4 = gr.Image(label="Optimización WebP con pérdida")
|
68 |
+
optimized_size4 = gr.Text(visible=False)
|
69 |
+
download_button4 = gr.Button("Descargar")
|
70 |
|
71 |
optimize_button.click(
|
72 |
fn=optimize_image,
|
73 |
inputs=image_input,
|
74 |
outputs=[
|
75 |
+
optimized_output1, optimized_size1, download_button1,
|
76 |
+
optimized_output2, optimized_size2, download_button2,
|
77 |
+
optimized_output3, optimized_size3, download_button3,
|
78 |
+
optimized_output4, optimized_size4, download_button4
|
79 |
]
|
80 |
)
|
81 |
|
82 |
+
download_button1.click(lambda x: x, inputs=optimized_size1, outputs=download_button1)
|
83 |
+
download_button2.click(lambda x: x, inputs=optimized_size2, outputs=download_button2)
|
84 |
+
download_button3.click(lambda x: x, inputs=optimized_size3, outputs=download_button3)
|
85 |
+
download_button4.click(lambda x: x, inputs=optimized_size4, outputs=download_button4)
|
86 |
+
|
87 |
demo.launch()
|