Center an image with it's default size

I have an image of size of 1138 x 656, i’m trying to simply center it.

background = Image.open("welcoming.jpg")
col1, col2, col3 = st.columns([0.2, 5, 0.2])
col2.image(background, width=1138)

but the image doesn’t seem to positioned in the center. how come?
can someone please explain, BTW I’m using an ultra wide screen.

Thank you all :slight_smile:

Hello @Chris_Evans, welcome to the forum!

If you fix your image width, it might overflow on your third column, thus not appearing centered.
Try to set use_column_width to True in col2.image() instead:

background = Image.open("welcoming.jpg")
col1, col2, col3 = st.columns([0.2, 5, 0.2])
col2.image(background, use_column_width=True)

Hi @okld thank you for the reply, but with modifying the code with your suggestion I keep getting a smaller size exactly as without the division of the page to columns.
It seems for some reason it ignores the columns. How come?