Streamlit image

Hey guys , is it possible to resize st.image’s height too ?

Hi @AYMEN_GADRI,

When you resize the width, the height will automatically adjust to keep the image proportional – so you can resize the height by just resizing the width.

Caroline

1 Like

Hey @Caroline ,
exactly , but I want to adjust the aspect-ratio so that the image is 16:9 , is there a way to do that ?
Thank you

Hi @AYMEN_GADRI - you can use w, h = Image.open(your_media_file).size from the PIL package to then compute the correct width for a 16:9 aspect ratio, which you pass to st.image.

A

2 Likes

hey @asehmi ,
Thank you , that’s what I did and it worked .
Thank you guys

1 Like