Skip to content

Instantly share code, notes, and snippets.

@rabbitix
Created January 22, 2021 16:45
Show Gist options
  • Save rabbitix/e79b9e4c709f0b1c25009069591a9848 to your computer and use it in GitHub Desktop.
Save rabbitix/e79b9e4c709f0b1c25009069591a9848 to your computer and use it in GitHub Desktop.
Convert a list of images to a pdf file
from PIL import Image
import os
path = "" # path to dir of photos
files = os.listdir(path)
files = ["./{}/{}".format(path,file) for file in files]
im_list = [Image.open(file) for file in files ]
pdf1_filename = "./output.pdf"
im1 = im_list[0]
im1.save(pdf1_filename, "PDF" ,resolution=100.0, save_all=True, append_images=im_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment