Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,8 +26,11 @@ def main():
|
|
| 26 |
try:
|
| 27 |
original_image = Image.open(uploaded_file)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
st.subheader("Originalbild")
|
| 30 |
-
st.image(original_image, caption="Ursprüngliches Bild")
|
| 31 |
|
| 32 |
original_size_bytes = len(uploaded_file.getvalue())
|
| 33 |
st.write(f"Ursprüngliche Bildgröße: {original_size_bytes} Bytes")
|
|
@@ -39,12 +42,14 @@ def main():
|
|
| 39 |
value=85
|
| 40 |
)
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
target_format = st.sidebar.selectbox(
|
| 43 |
"Zielformat",
|
| 44 |
-
|
| 45 |
)
|
| 46 |
|
| 47 |
-
# Warnung vor mehrfachem Klicken
|
| 48 |
st.warning("⚠️ Bitte klicken Sie NUR EINMAL auf 'Bild optimieren'!")
|
| 49 |
|
| 50 |
progress_bar = st.progress(0)
|
|
|
|
| 26 |
try:
|
| 27 |
original_image = Image.open(uploaded_file)
|
| 28 |
|
| 29 |
+
# Aktuelles Format ermitteln
|
| 30 |
+
current_format = original_image.format.lower() if original_image.format else uploaded_file.name.split('.')[-1].lower()
|
| 31 |
+
|
| 32 |
st.subheader("Originalbild")
|
| 33 |
+
st.image(original_image, caption=f"Ursprüngliches Bild ({current_format.upper()})")
|
| 34 |
|
| 35 |
original_size_bytes = len(uploaded_file.getvalue())
|
| 36 |
st.write(f"Ursprüngliche Bildgröße: {original_size_bytes} Bytes")
|
|
|
|
| 42 |
value=85
|
| 43 |
)
|
| 44 |
|
| 45 |
+
# Zielformate ohne aktuelles Format
|
| 46 |
+
target_formats = [fmt for fmt in ['webp', 'jpg', 'png'] if fmt != current_format]
|
| 47 |
+
|
| 48 |
target_format = st.sidebar.selectbox(
|
| 49 |
"Zielformat",
|
| 50 |
+
target_formats
|
| 51 |
)
|
| 52 |
|
|
|
|
| 53 |
st.warning("⚠️ Bitte klicken Sie NUR EINMAL auf 'Bild optimieren'!")
|
| 54 |
|
| 55 |
progress_bar = st.progress(0)
|