Search code examples
tiffstreamlit

Streamlit - How to show .tif images (possibly large size) in Streamlit using st.image?


I am trying to visualize high resolution *.tif images using streamlit. I tried using both a url to the image and the downloaded image. All I get is a "0" similar to a st.write("0").

What I tried to do:

import streamlit as st

st.image("http://www.bmsc.washington.edu/raster3d/examples/density.tiff")

Solution

  • You can use the pillow library.

    import streamlit as st 
    from PIL import Image
    
    
    fn = 'f:/downloads/density.tiff'
    image = Image.open(fn)
    st.image(image)
    

    Output

    enter image description here