forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathst_image.py
More file actions
59 lines (46 loc) · 1.99 KB
/
Copy pathst_image.py
File metadata and controls
59 lines (46 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright 2018-2021 Streamlit Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import streamlit as st
import numpy as np
img = np.repeat(0, 10000).reshape(100, 100)
img800 = np.repeat(0, 640000).reshape(800, 800)
st.image(img, caption="Black Square as JPEG", output_format="JPEG", width=100)
st.image(img, caption="Black Square as PNG", output_format="PNG", width=100)
st.image(img, caption="Black Square with no output format specified", width=100)
transparent_img = np.zeros((100, 100, 4), dtype=np.uint8)
st.image(transparent_img, caption="Transparent Black Square", width=100)
col1, col2, col3 = st.beta_columns(3)
col2.image(img) # 100
col2.image(img, use_column_width="auto") # 100
col2.image(img, use_column_width="never") # 100
col2.image(img, use_column_width=False) # 100
col2.image(img, use_column_width="always") # column
col2.image(img, use_column_width=True) # column
col2.image(img800, use_column_width="auto") # column
st.image(
"""<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100">
<clipPath id="clipCircle">
<circle r="25" cx="25" cy="25"/>
</clipPath>
<image href="https://avatars.githubusercontent.com/karriebear" width="50" height="50" clip-path="url(#clipCircle)"/>
</svg>
"""
)
st.image(
"""
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="100">
<text x="0" y="50">"I am a quote" - https://avatars.githubusercontent.com/karriebear</text>
</svg>
"""
)