Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

download button image streamlit

def get_image_download_link(img):
	"""Generates a link allowing the PIL image to be downloaded
	in:  PIL image
	out: href string
	"""
	buffered = BytesIO()
	img.save(buffered, format="JPEG")
	img_str = base64.b64encode(buffered.getvalue()).decode()
	href = f'<a href="data:file/jpg;base64,{img_str}" download ="result.jpg">Download result</a>'
	return href
  st.image(img, caption=f"Image Predicted")
  result = Image.fromarray(img)
  st.markdown(get_image_download_link(result), unsafe_allow_html=True)
 
PREVIOUS NEXT
Tagged: #download #button #image #streamlit
ADD COMMENT
Topic
Name
6+2 =