Format_Your_Image / src /app /image_conversion.py
Vela
updated resize function
50a42c6
from ..modules import home_page
import os
def get_file_path(uploaded_file):
if not os.path.exists("temp"):
os.makedirs("temp")
file_path = os.path.join("temp", uploaded_file.name)
with open(file_path, "wb") as f:
f.write(uploaded_file.getbuffer())
return file_path
def display_converted_image(st, option, file_path):
if option =="change_to_rgb":
file = home_page.change_image_color_format(file_path,"RGB")
st.image(file, width=500)
elif option == "change_to_bgr":
file = home_page.change_image_color_format(file_path,"BGR")
st.image(file, width=500)
elif option == "change_to_grayscale":
file = home_page.change_image_color_format(file_path,"Grayscale")
st.image(file, width=500)
elif option == "rotate":
angle = st.slider("Select Rotation Angle", min_value=0, max_value=360, value=0, step=1)
if angle:
file = home_page.change_image_color_format(file_path,"Rotate",angle)
st.image(file, width=500)
elif option == "increase_brightness":
brightness_factor = st.slider("Select Brightness Factor", min_value=0.5, max_value=3.0, value=1.2, step=0.1)
file = home_page.change_image_color_format(file_path,"increase_brightness",factor=brightness_factor)
st.image(file, caption="Brightened Image", width=500)
elif option == "blur_image":
file = home_page.change_image_color_format(file_path,"Blur_Image")
st.image(file, width=500)
elif option == "resize_image":
file=home_page.change_image_color_format(file_path,"resize_image")
st.image(file, width=500)