#이미지/동영상/음악파일을 화면에 보여주는 방법
import streamlit as st
#이미지 처리를 위한 라이브럴
from PIL import Image #파이썬 이미지 라이브러리 PIL
def main():
# 1. 저장되어있는 이미지 파일을 화면에 표시하는 방법
img = Image.open('./data/image_03.jpg')
st.image(img)
st.image(img, width=500)
st.image(img, use_column_width=True) #width=True해주면 자동으로 폭을 맞춰준다
#2. 인터넷상에 있는 이미지를 화면에 표시하는 방법 인터넷상의 이미지:URL이 있다
#사진 파일 (움직이는 gif사진도 가능하다)
url = 'https://miro.medium.com/v2/resize:fit:1000/format:webp/1*_ruPoPC4tiUP9Ojtiec4nw.gif'
st.image(url)
#동영상 파일
video_file = open('./data/video1.mp4','rb') #rb = read binary
st.video(video_file)
#오디오 파일
audio_file = open('./data/song.mp3', 'rb')
st.audio(audio_file.read(), format='audio/mp3')
if __name__ == '__main__':
main()
'Python > Streamlit' 카테고리의 다른 글
Streamlit) 웹페이지에 파일 업로드 장치를 만들고 파일 저장시키기 (0) | 2024.04.26 |
---|---|
Streamlit) 웹페이지에서 유저에게 숫자, 문자, 시간, 색 입력 받기 (2) | 2024.04.26 |
Streamlit) UI함수를 사용하여 버튼 만들기 (0) | 2024.04.26 |
Streamlit) 웹 페이지에 다양한 텍스트 표시하기 (0) | 2024.04.26 |
Streamlit) 임포트(import)하여 웹페이지 만들기 (0) | 2024.04.26 |