razaAhmed commited on
Commit
cc6d184
·
1 Parent(s): ba49d4c

Upload 2 files

Browse files
Files changed (2) hide show
  1. requirements.txt +60 -0
  2. webtopng.py +46 -0
requirements.txt ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==5.2.0
2
+ appdirs==1.4.4
3
+ attrs==23.1.0
4
+ blinker==1.7.0
5
+ cachetools==5.3.2
6
+ certifi==2023.11.17
7
+ charset-normalizer==3.3.2
8
+ click==8.1.7
9
+ exceptiongroup==1.2.0
10
+ gitdb==4.0.11
11
+ GitPython==3.1.40
12
+ h11==0.14.0
13
+ idna==3.6
14
+ importlib-metadata==6.11.0
15
+ Jinja2==3.1.2
16
+ jsonschema==4.20.0
17
+ jsonschema-specifications==2023.11.2
18
+ markdown-it-py==3.0.0
19
+ MarkupSafe==2.1.3
20
+ mdurl==0.1.2
21
+ numpy==1.26.2
22
+ outcome==1.3.0.post0
23
+ packaging==23.2
24
+ pandas==2.1.4
25
+ Pillow==10.1.0
26
+ protobuf==4.25.1
27
+ pyarrow==14.0.1
28
+ pydeck==0.8.1b0
29
+ pyee==8.2.2
30
+ Pygments==2.17.2
31
+ pyppeteer==1.0.2
32
+ PySocks==1.7.1
33
+ python-dateutil==2.8.2
34
+ pytz==2023.3.post1
35
+ referencing==0.32.0
36
+ requests==2.31.0
37
+ rich==13.7.0
38
+ rpds-py==0.13.2
39
+ selenium==4.16.0
40
+ six==1.16.0
41
+ smmap==5.0.1
42
+ sniffio==1.3.0
43
+ sortedcontainers==2.4.0
44
+ streamlit==1.29.0
45
+ tenacity==8.2.3
46
+ toml==0.10.2
47
+ toolz==0.12.0
48
+ tornado==6.4
49
+ tqdm==4.66.1
50
+ trio==0.23.2
51
+ trio-websocket==0.11.1
52
+ typing_extensions==4.9.0
53
+ tzdata==2023.3
54
+ tzlocal==5.2
55
+ urllib3==1.26.18
56
+ validators==0.22.0
57
+ watchdog==3.0.0
58
+ websockets==10.4
59
+ wsproto==1.2.0
60
+ zipp==3.17.0
webtopng.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ from io import BytesIO
4
+
5
+ def main():
6
+ st.title("WEB to PNG Converter")
7
+
8
+ # Upload image through Streamlit
9
+ uploaded_file = st.file_uploader("Choose an image file", type=["webp"])
10
+
11
+ if uploaded_file is not None:
12
+ st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
13
+
14
+ # Convert image to PNG
15
+ converted_image = convert_to_png(uploaded_file)
16
+
17
+ # Display the converted image
18
+ st.image(converted_image, caption="Converted Image", use_column_width=True)
19
+
20
+ # Offer download link for the converted image
21
+ download_link(converted_image, "Download Converted Image")
22
+
23
+ def convert_to_png(image_file):
24
+ # Open the uploaded image using PIL
25
+ img = Image.open(image_file)
26
+
27
+ # Convert to PNG format
28
+ img_png = img.convert("RGBA")
29
+
30
+ return img_png
31
+
32
+ def download_link(image, text):
33
+ # Create a downloadable link for the converted image
34
+ with st.spinner("Converting..."):
35
+ img_bytes = BytesIO()
36
+ image.save(img_bytes, format="PNG")
37
+
38
+ st.download_button(
39
+ label=text,
40
+ data=img_bytes.getvalue(),
41
+ file_name="converted_image.png",
42
+ key="download_button"
43
+ )
44
+
45
+ if __name__ == "__main__":
46
+ main()