Automated update
64
all.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
import glob
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print("Usage: {} output.pdf image1 [image2 ...]".format(sys.argv[0]))
|
||||||
|
print("Example: {} lab1.pdf ~/path/*".format(sys.argv[0]))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
output_pdf = sys.argv[1]
|
||||||
|
input_args = sys.argv[2:]
|
||||||
|
|
||||||
|
# Build the list of image files.
|
||||||
|
file_list = []
|
||||||
|
for arg in input_args:
|
||||||
|
# If the argument contains a wildcard, expand it.
|
||||||
|
if any(ch in arg for ch in '*?['):
|
||||||
|
expanded = glob.glob(arg)
|
||||||
|
file_list.extend(expanded)
|
||||||
|
else:
|
||||||
|
file_list.append(arg)
|
||||||
|
|
||||||
|
# Filter for PNG and JPG files (case-insensitive)
|
||||||
|
file_list = [f for f in file_list if f.lower().endswith(('.png', '.jpg', '.jpeg'))]
|
||||||
|
|
||||||
|
if not file_list:
|
||||||
|
print("No PNG/JPG images found.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Sort the file list (optional, but usually helpful)
|
||||||
|
file_list.sort()
|
||||||
|
|
||||||
|
# Open and convert images to RGB (required for PDF conversion)
|
||||||
|
images = []
|
||||||
|
for file in file_list:
|
||||||
|
try:
|
||||||
|
img = Image.open(file)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error opening {file}: {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Convert image mode if necessary
|
||||||
|
if img.mode != 'RGB':
|
||||||
|
img = img.convert('RGB')
|
||||||
|
images.append(img)
|
||||||
|
|
||||||
|
if not images:
|
||||||
|
print("No valid images to convert.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Save the images as a single PDF. The first image is used as a base,
|
||||||
|
# and the rest are appended.
|
||||||
|
try:
|
||||||
|
images[0].save(output_pdf, "PDF", resolution=100.0, save_all=True, append_images=images[1:])
|
||||||
|
print(f"Saved PDF as {output_pdf}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error saving PDF: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
BIN
convertionstobedone/IMG_8024.jpg
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
convertionstobedone/IMG_8047.jpg
Normal file
|
After Width: | Height: | Size: 981 KiB |
BIN
convertionstobedone/IMG_8048.jpg
Normal file
|
After Width: | Height: | Size: 2.4 MiB |
BIN
convertionstobedone/IMG_8049.jpg
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
BIN
convertionstobedone/IMG_8050.jpg
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
convertionstobedone/IMG_8051.jpg
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
convertionstobedone/IMG_8052.jpg
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
convertionstobedone/IMG_8053.jpg
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
convertionstobedone/IMG_8054.jpg
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
convertionstobedone/IMG_8055.jpg
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
convertionstobedone/IMG_8056.jpg
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
convertionstobedone/IMG_8057.jpg
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
BIN
convertionstobedone/IMG_8058.jpg
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
convertionstobedone/IMG_8059.jpg
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
convertionstobedone/IMG_8060.jpg
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
convertionstobedone/IMG_8061.jpg
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
convertionstobedone/IMG_8062.jpg
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
BIN
convertionstobedone/IMG_8063.jpg
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
convertionstobedone/IMG_8064.jpg
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
convertionstobedone/IMG_8065.jpg
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
convertionstobedone/IMG_8066.jpg
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
convertionstobedone/IMG_8067.jpg
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
convertionstobedone/IMG_8068.jpg
Normal file
|
After Width: | Height: | Size: 1006 KiB |
BIN
convertionstobedone/IMG_8069.jpg
Normal file
|
After Width: | Height: | Size: 956 KiB |
BIN
convertionstobedone/graph1.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
convertionstobedone/graph2.png
Normal file
|
After Width: | Height: | Size: 64 KiB |