Update app.py
Browse files
app.py
CHANGED
@@ -33,23 +33,28 @@ def generate_pdf(images_with_sequence):
|
|
33 |
return None
|
34 |
return pdf_name
|
35 |
|
36 |
-
st.
|
|
|
37 |
|
38 |
uploaded_images = st.file_uploader("Upload Images", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
|
39 |
|
40 |
if uploaded_images:
|
41 |
num_images = len(uploaded_images)
|
42 |
if num_images > 0: # Check if any image is uploaded
|
|
|
43 |
images_with_sequence = []
|
44 |
|
45 |
for i, image_file in enumerate(uploaded_images):
|
46 |
-
st.
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
53 |
|
54 |
if st.button("Generate PDF"):
|
55 |
pdf_name = generate_pdf(images_with_sequence)
|
@@ -62,4 +67,4 @@ if uploaded_images:
|
|
62 |
os.remove(f"temp_image_{i}.jpg")
|
63 |
os.remove(pdf_name) # Remove the file after download
|
64 |
else:
|
65 |
-
st.write("Please upload images to continue")
|
|
|
33 |
return None
|
34 |
return pdf_name
|
35 |
|
36 |
+
st.markdown("<h1 style='text-align: center; color: #00698f;'>Image to PDF Converter</h1>", unsafe_allow_html=True)
|
37 |
+
st.markdown("<h3 style='text-align: center; color: #0086b3;'>Supports multiple image upload at once and rearrangement of pages</h3>", unsafe_allow_html=True)
|
38 |
|
39 |
uploaded_images = st.file_uploader("Upload Images", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
|
40 |
|
41 |
if uploaded_images:
|
42 |
num_images = len(uploaded_images)
|
43 |
if num_images > 0: # Check if any image is uploaded
|
44 |
+
st.write("**Uploaded Images:**")
|
45 |
images_with_sequence = []
|
46 |
|
47 |
for i, image_file in enumerate(uploaded_images):
|
48 |
+
col1, col2 = st.columns([3, 1])
|
49 |
+
with col1:
|
50 |
+
st.image(image_file, width=250)
|
51 |
+
with col2:
|
52 |
+
sequence_options = [str(j) for j in range(1, num_images + 1)]
|
53 |
+
default_index = i # Set default selection of sequence as the order of upload
|
54 |
+
sequence_number = st.selectbox(f"Sequence {i+1}", sequence_options, index=default_index)
|
55 |
+
processed_image, processed_sequence = process_image(image_file, int(sequence_number))
|
56 |
+
if processed_image:
|
57 |
+
images_with_sequence.append((processed_image, processed_sequence))
|
58 |
|
59 |
if st.button("Generate PDF"):
|
60 |
pdf_name = generate_pdf(images_with_sequence)
|
|
|
67 |
os.remove(f"temp_image_{i}.jpg")
|
68 |
os.remove(pdf_name) # Remove the file after download
|
69 |
else:
|
70 |
+
st.write("Please upload images to continue")
|