Resizing images from the folder

Hi! as a group, we are totally new to streamlit in our movie recommendation system. Now, we are dealing with taking pictures from our local folder which is consisting of 2214 pictures. We added our path like this:

path = "Path\\To\\Folder"
list = os.listdir(path)

For displaying image we are using st.image and it looks like in the below:

st.image(image, caption=list[i][:-4], use_column_width=True)

col1, col2, col3, col4 = st.columns(4)

It looks like we are not able to set with both width and height :frowning: For a better understanding, I want to share that how we ranged our columns:

with col1 :
      for i in range(int(len(list) / 4)) :
      image = + list[i])
      # ...
with col2 :
      for i in range(738,int(len(list)/2)) :
      # ...
with col3 :
     for i in range(1475,2213) :
     # ...
with col4 :
    for i in range(2214,int(len(list))) :
    # ...

I think the only problem is resizing them but we do not have any idea of how we are going to implement it. What is your suggestions to deal with this issue ?

Hi @orhanea, welcome to the Streamlit community!

This is a difficult problem to solve via the front-end, as however the images come in they already have a specific aspect ratio. So while you maybe be able to set the width or height within Streamlit, it’d be a better design to normalize all of your images before trying to display them. Once your 2214 images are a consistent size, then you no longer have to worry about the front-end.


1 Like