-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
61 lines (50 loc) · 1.54 KB
/
app.py
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
60
61
import streamlit as st
from PIL import Image
import pillow_heif
import zipfile
import io
pillow_heif.register_heif_opener()
def convert_heif_to_jpeg(file):
# HEIF/HEICファイルの読み込み
image = Image.open(file)
return image
st.title("HEIF/HEIC to JPEG Converter")
uploaded_files = st.file_uploader("Drop HEIF/HEIC files", type=["heif", "heic"], accept_multiple_files=True)
st.write("ドラッグ&ドロップで複数ファイルをアップロードできます")
if uploaded_files:
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, "w") as zip_file:
for uploaded_file in uploaded_files:
image = convert_heif_to_jpeg(uploaded_file)
# JPEG変換
img_byte_arr = io.BytesIO()
image.save(img_byte_arr, format="JPEG", quality=95)
img_byte_arr.seek(0)
# ZIP
zip_file.writestr(f"{uploaded_file.name.split('.')[0]}.jpeg", img_byte_arr.read())
zip_buffer.seek(0)
# ZIPダウンロード
st.download_button(
label="Download ZIP",
data=zip_buffer,
file_name="converted_images.zip",
mime="application/zip",
)
footer = """
<style>
.footer {
position: fixed;
bottom: 0;
right: 0;
width: 100%;
text-align: right;
padding: 10px;
font-size: 12px;
color: #555;
}
</style>
<div class="footer">
<p>© 2024 ICT Lab.</p>
</div>
"""
st.markdown(footer, unsafe_allow_html=True)