Automated update

This commit is contained in:
klein panic
2025-02-07 22:05:56 -05:00
parent 2d83acdaf5
commit c6de6fd34b
28 changed files with 64 additions and 0 deletions

64
all.py Normal file
View 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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
lab01.pdf Normal file

Binary file not shown.