Hi @Nadia_Liaquat, welcome to the Streamlit community!
There are a couple of ways to go about it. You could do
newimg = uploaded_file to assign the input data to another variable
If you’re used to working with PIL to process images, you could convert
uploaded_file to a PIL image, and use
PIL.Image.copy() to copy the image to another variable.
Here’s an example with both methods:
import streamlit as st
from PIL import Image
# upload image
uploaded_file = st.file_uploader("Upload image", type=['png', 'jpg'])
# check if image is uploaded
# display uploaded image
image = st.image(uploaded_file, caption="original image", width=300)
# copy uploaded_file and display copy
newimg = uploaded_file
st.image(newimg, caption="newimg", width=100)
# open uploaded_file as PIL image
pil_img = Image.open(uploaded_file)
image = st.image(pil_img, caption="PIL image")
# use PIL.Image.copy() and display copied image
newimg = pil_img.copy() # "copy the input data in another variable"
st.image(newimg, caption="Copy of PIL image", width=200)
Hope this helps! Let us know if you have follow-up questions