streamlit-cropper
streamlit-cropper copied to clipboard
Cropper doesn't render when loading .png file from sidebar in a different tab
Consider the following code snippet
from streamlit_cropper import st_cropper
import streamlit as st
from PIL import Image
tab_1, tab_2 = st.tabs(["TAB-1", "TAB-2"])
img_file = st.sidebar.file_uploader(
label='Upload a file',
type=['png', 'jpg'])
if img_file:
img = Image.open(img_file)
with tab_1:
st.write("This is TAB 1.")
with tab_2:
if img_file:
cropped_img = st_cropper(img, realtime_update=True,
box_color='#0000FF', aspect_ratio=(1, 1))
st.write("This is TAB 2.")
The cropper widget shows up when I'm in tab 2 when uploading the .png file, but it does not show up when I'm viewing tab 1, upload a .png file, and then switch to tab 2. Am I doing something wrong?
This one's honestly a headscratcher, st.image works in this same scenario, maybe it's something about how components are rendered. Do you know if this works with other components? I haven't had a chance to test. What's odd is the component is there in the HTML but height is set to 0 for some reason.