函數簽名
st.image(image, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto")
參數 | 說明 |
---|---|
image (numpy.ndarray, [numpy.ndarray], BytesIO, str, or [str]) | 形狀 (w,h) 或 (w,h,1) 的單色圖像或形狀 (w,h,3) 的彩色圖像或形狀 (w,h,4) 的 RGBA 圖像或獲取圖像的 URL從 OR 本Map像文件的路徑或 SVG XML 字符串(如 |
caption (str or list of str) | 圖片說明。如果顯示多個圖像,標題應該是標題列表(每個圖像一個)。 |
width (int or None) | 圖像寬度。 None 表示使用圖像寬度,但不要超過列的寬度。應該為 SVG 圖像設置,因為它們沒有默認的圖像寬度。 |
use_column_width ('auto' or 'always' or 'never' or bool) | 如果'auto',將圖像的寬度設置為其自然大小,但不要超過列的寬度。如果'always' 或 True,將圖像的寬度設置為列寬。如果 'never' 或 False,將圖像的寬度設置為其自然大小。注意:如果設置, |
clamp (bool) | 將圖像像素值限製在有效範圍內(每個通道 [0-255])。這僅對字節數組圖像有意義;對於圖像 URL,該參數將被忽略。如果未設置,並且圖像具有超出範圍的值,則會引發錯誤。 |
channels ('RGB' or 'BGR') | 如果 image 是一個 nd.array,這個參數表示用於表示顏色信息的格式。默認為'RGB',意味著 |
output_format ('JPEG', 'PNG', or 'auto') | 此參數指定傳輸圖像數據時使用的格式。照片應使用 JPEG 格式進行有損壓縮,而圖表應使用 PNG 格式進行無損壓縮。默認為'auto',它根據圖像參數的類型和格式識別壓縮類型。 |
示例
from PIL import Image
image = Image.open('sunrise.jpg')
st.image(image, caption='Sunrise by the mountains')
相關用法
- Python Streamlit st.info用法及代碼示例
- Python Streamlit st.experimental_singleton.clear用法及代碼示例
- Python Streamlit st.bokeh_chart用法及代碼示例
- Python Streamlit st.caption用法及代碼示例
- Python Streamlit st.text_input用法及代碼示例
- Python Streamlit st.area_chart用法及代碼示例
- Python Streamlit st.title用法及代碼示例
- Python Streamlit st.cache用法及代碼示例
- Python Streamlit st.experimental_singleton用法及代碼示例
- Python Streamlit st.empty用法及代碼示例
- Python Streamlit st.error用法及代碼示例
- Python Streamlit st.video用法及代碼示例
- Python Streamlit st.vega_lite_chart用法及代碼示例
- Python Streamlit st.slider用法及代碼示例
- Python Streamlit st.header用法及代碼示例
- Python Streamlit st.container用法及代碼示例
- Python Streamlit st.form_submit_button用法及代碼示例
- Python Streamlit st.form用法及代碼示例
- Python Streamlit st.plotly_chart用法及代碼示例
- Python Streamlit st.bar_chart用法及代碼示例
- Python Streamlit st.code用法及代碼示例
- Python Streamlit st.experimental_memo.clear用法及代碼示例
- Python Streamlit st.warning用法及代碼示例
- Python Streamlit st.markdown用法及代碼示例
- Python Streamlit st.expander用法及代碼示例
注:本文由純淨天空篩選整理自streamlit.io大神的英文原創作品 st.image。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。