Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
|
|
3 |
|
4 |
# Ambil daftar format gambar yang didukung oleh Pillow
|
5 |
supported_formats = sorted(Image.SAVE.keys())
|
@@ -9,8 +10,11 @@ def convert_image(image, target_format):
|
|
9 |
# Buka file gambar
|
10 |
img = Image.open(image)
|
11 |
|
12 |
-
#
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
# Simpan gambar dalam format yang dipilih
|
16 |
img.save(output_file, format=target_format.upper())
|
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
+
import os
|
4 |
|
5 |
# Ambil daftar format gambar yang didukung oleh Pillow
|
6 |
supported_formats = sorted(Image.SAVE.keys())
|
|
|
10 |
# Buka file gambar
|
11 |
img = Image.open(image)
|
12 |
|
13 |
+
# Ambil nama file asli tanpa ekstensi
|
14 |
+
base_name = os.path.splitext(os.path.basename(image))[0]
|
15 |
+
|
16 |
+
# Nama file keluaran dengan awalan yang diinginkan
|
17 |
+
output_file = f"flowly_ai_image_converter_{base_name}.{target_format.lower()}"
|
18 |
|
19 |
# Simpan gambar dalam format yang dipilih
|
20 |
img.save(output_file, format=target_format.upper())
|