I am trying to save my images into a directory. This is working fine but it is shuffling the images. I dont want them to be shuffled. I want it to be arranged the way it is uploaded
@st.cache
#defining a function to load image
def load_image(image_file):
img=Image.open(image_file)
return img
#creating a directory
dir = "Bre"
try:
os.mkdir(dir)
print ("Directory is created")
except FileExistsError:
print ("Directory already exists")
def main():
image_file=st.file_uploader('upload Image', type=['png', 'jpg', 'jpeg'], accept_multiple_files=True,)
if image_file is not None:
for image in image_file:
file_details = {"FileName":image.name,"FileType":image.type}
st.write(file_details)
img = load_image(image)
st.image(img)
#saving file
with open(os.path.join("Bre",image.name),"wb") as f:
f.write(image.getbuffer())
st.success("Saved File")
if __name__ == "__main__":
main()