Spaces:
Paused
Paused
Create app.py
Browse files1234567891011121314151617181920212223242526272829303132333435import streamlit as stfrom PIL import Imageimport io
# Supported formatsformats = ['JPEG', 'PNG', 'BMP', 'GIF', 'TIFF']
st.title("Image Format Converter")
# Upload an image fileuploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png", "bmp", "gif", "tiff"])
if uploaded_file is not None: # Open the image image = Image.open(uploaded_file) st.image(image, caption="Uploaded Image", use_column_width=True) # Select the format to convert to st.write("Select the format to convert to:") format_to_convert = st.selectbox("Format", formats) if st.button("Convert"): # Convert the image img_byte_arr = io.BytesIO() image.save(img_byte_arr, format=format_to_convert) img_byte_arr = img_byte_arr.getvalue() # Provide a download link st.write("Conversion Successful!") st.download_button( label="Download converted image", data=img_byte_arr, file_name=f"converted_image.{format_to_convert.lower()}", mime=f"image/{format_to_convert.lower()}" )app.pyAdded+35