Spaces:
Running
Running
Commit
·
ff94bd2
1
Parent(s):
5717b13
file upload gallery
Browse files
app.py
CHANGED
|
@@ -599,19 +599,20 @@ def display_image_gallery():
|
|
| 599 |
"""
|
| 600 |
Display an image gallery from st.session_state['input_list'] in a scrollable container.
|
| 601 |
Each image will be downsampled to 120px on the long side.
|
|
|
|
| 602 |
"""
|
| 603 |
# Initialize the container
|
| 604 |
con_image = st.empty()
|
| 605 |
with con_image.container():
|
| 606 |
-
# Start the gallery HTML with a div that will create a
|
| 607 |
-
gallery_html = "<div style='display: flex; flex-wrap:
|
| 608 |
|
| 609 |
# Loop through each image in the input list
|
| 610 |
for image_path in st.session_state['input_list']:
|
| 611 |
# Open the image
|
| 612 |
img = Image.open(image_path)
|
| 613 |
# Downsample the image to 120px on the long side
|
| 614 |
-
img.thumbnail((120, 120))
|
| 615 |
|
| 616 |
# Convert the image to base64 for HTML embedding
|
| 617 |
buffered = io.BytesIO()
|
|
@@ -620,8 +621,8 @@ def display_image_gallery():
|
|
| 620 |
|
| 621 |
# Add each image to the gallery HTML
|
| 622 |
gallery_html += f"""
|
| 623 |
-
<div style='padding: 5px;'>
|
| 624 |
-
<img src='data:image/jpeg;base64,{img_str}' alt='Image' style='height: 120px;
|
| 625 |
</div>
|
| 626 |
"""
|
| 627 |
|
|
|
|
| 599 |
"""
|
| 600 |
Display an image gallery from st.session_state['input_list'] in a scrollable container.
|
| 601 |
Each image will be downsampled to 120px on the long side.
|
| 602 |
+
The container will be as wide as its containing Streamlit column and no more than 400px tall.
|
| 603 |
"""
|
| 604 |
# Initialize the container
|
| 605 |
con_image = st.empty()
|
| 606 |
with con_image.container():
|
| 607 |
+
# Start the gallery HTML with a div that will create a vertical scrolling effect
|
| 608 |
+
gallery_html = "<div style='display: flex; flex-wrap: wrap; overflow-y: auto; max-height: 400px;'>"
|
| 609 |
|
| 610 |
# Loop through each image in the input list
|
| 611 |
for image_path in st.session_state['input_list']:
|
| 612 |
# Open the image
|
| 613 |
img = Image.open(image_path)
|
| 614 |
# Downsample the image to 120px on the long side
|
| 615 |
+
img.thumbnail((120, 120), Image.ANTIALIAS)
|
| 616 |
|
| 617 |
# Convert the image to base64 for HTML embedding
|
| 618 |
buffered = io.BytesIO()
|
|
|
|
| 621 |
|
| 622 |
# Add each image to the gallery HTML
|
| 623 |
gallery_html += f"""
|
| 624 |
+
<div style='padding: 5px; flex: 1 0 auto;'>
|
| 625 |
+
<img src='data:image/jpeg;base64,{img_str}' alt='Image' style='max-height: 120px; width: auto;'>
|
| 626 |
</div>
|
| 627 |
"""
|
| 628 |
|