Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +34 -0
- requirements.txt +45 -0
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from io import BytesIO
|
| 5 |
+
|
| 6 |
+
def download_image(url):
|
| 7 |
+
response = requests.get(url)
|
| 8 |
+
img = Image.open(BytesIO(response.content))
|
| 9 |
+
return img
|
| 10 |
+
|
| 11 |
+
st.title('Image Downloader')
|
| 12 |
+
|
| 13 |
+
url = st.text_input('Enter the image URL')
|
| 14 |
+
submit = st.button('Submit')
|
| 15 |
+
|
| 16 |
+
if url and submit:
|
| 17 |
+
try:
|
| 18 |
+
image = download_image(url)
|
| 19 |
+
st.image(image, caption='Download Image', use_column_width=True)
|
| 20 |
+
|
| 21 |
+
# Convert image to bytes
|
| 22 |
+
img_byte_arr = BytesIO()
|
| 23 |
+
image.save(img_byte_arr, format='PNG')
|
| 24 |
+
img_byte_arr = img_byte_arr.getvalue()
|
| 25 |
+
|
| 26 |
+
# Add download button
|
| 27 |
+
st.download_button(
|
| 28 |
+
label="Download Image",
|
| 29 |
+
data=img_byte_arr,
|
| 30 |
+
file_name='downloaded_image.png',
|
| 31 |
+
mime='image/png'
|
| 32 |
+
)
|
| 33 |
+
except Exception as e:
|
| 34 |
+
st.error(f'Error: {e}')
|
requirements.txt
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
altair==5.2.0
|
| 2 |
+
attrs==23.1.0
|
| 3 |
+
blinker==1.7.0
|
| 4 |
+
cachetools==5.3.2
|
| 5 |
+
certifi==2023.11.17
|
| 6 |
+
charset-normalizer==3.3.2
|
| 7 |
+
click==8.1.7
|
| 8 |
+
gitdb==4.0.11
|
| 9 |
+
GitPython==3.1.40
|
| 10 |
+
idna==3.6
|
| 11 |
+
importlib-metadata==6.11.0
|
| 12 |
+
Jinja2==3.1.2
|
| 13 |
+
jsonschema==4.20.0
|
| 14 |
+
jsonschema-specifications==2023.11.2
|
| 15 |
+
markdown-it-py==3.0.0
|
| 16 |
+
MarkupSafe==2.1.3
|
| 17 |
+
mdurl==0.1.2
|
| 18 |
+
numpy==1.26.2
|
| 19 |
+
packaging==23.2
|
| 20 |
+
pandas==2.1.4
|
| 21 |
+
Pillow==10.1.0
|
| 22 |
+
protobuf==4.25.1
|
| 23 |
+
pyarrow==14.0.2
|
| 24 |
+
pydeck==0.8.1b0
|
| 25 |
+
Pygments==2.17.2
|
| 26 |
+
python-dateutil==2.8.2
|
| 27 |
+
pytz==2023.3.post1
|
| 28 |
+
referencing==0.32.0
|
| 29 |
+
requests==2.31.0
|
| 30 |
+
rich==13.7.0
|
| 31 |
+
rpds-py==0.15.2
|
| 32 |
+
six==1.16.0
|
| 33 |
+
smmap==5.0.1
|
| 34 |
+
streamlit==1.29.0
|
| 35 |
+
tenacity==8.2.3
|
| 36 |
+
toml==0.10.2
|
| 37 |
+
toolz==0.12.0
|
| 38 |
+
tornado==6.4
|
| 39 |
+
typing_extensions==4.9.0
|
| 40 |
+
tzdata==2023.3
|
| 41 |
+
tzlocal==5.2
|
| 42 |
+
urllib3==2.1.0
|
| 43 |
+
validators==0.22.0
|
| 44 |
+
watchdog==3.0.0
|
| 45 |
+
zipp==3.17.0
|