st.image() in Streamlit

In Streamlit, the st.image() function is used to display images in your web app. It supports local files, URLs, NumPy arrays, and PIL images, making it flexible for dashboards, ML apps, and data visualization.

Basic Syntax

st.image(image, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto")    

The function has the following parameters:

Example: Display a local image.

Python

import streamlit as st

st.title("Local Image Example")

# Display image from local folder
st.image("cat.jpg", caption="My Cat", width=300)    

Example: Display an image from a URL.

Python

import streamlit as st

st.image(
    "https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d",
    caption="Image from Internet"
)