Skip to content

Instantly share code, notes, and snippets.

@bunnykek
Created October 16, 2022 16:59
Show Gist options
  • Save bunnykek/08a1583eba0ee477a14febc54f212c77 to your computer and use it in GitHub Desktop.
Save bunnykek/08a1583eba0ee477a14febc54f212c77 to your computer and use it in GitHub Desktop.
Compiles all the images into a single pdf
#put this run.py file in the folder containing all the images.
from PIL import Image
import os
image_list = []
files = os.listdir()
image_files = []
for i in range(len(files)):
if files[i].endswith(".png"): #change the "png" according to the requirements.
image_files.append(files[i])
for i in range(len(image_files)):
image = Image.open(image_files[i]).convert('RGB')
image_list.append(image)
if i == 0:
image_list.pop()
base_img = image
base_img.save('compiled.pdf', save_all=True, append_images=image_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment