Skip to content

Instantly share code, notes, and snippets.

@Proteusiq
Created June 11, 2021 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Proteusiq/aa6d169eccf40d9e09f41d86d8df68ec to your computer and use it in GitHub Desktop.
Save Proteusiq/aa6d169eccf40d9e09f41d86d8df68ec to your computer and use it in GitHub Desktop.
from pathlib import Path
from PIL import Image
# get all png images from folder `gotoslides`
SLIDES_IMAGES = Path("gotoslides").glob("*.png")
# maybe use a generator | convert RGB (since its png)
images = [Image.open(image).convert("RGB") for image in SLIDES_IMAGES]
with open("gotoslides.pdf", "wb") as pdf_file:
first_image, *rest_images = images
first_image.save(
pdf_file, "PDF", resolution=100, save_all=True, append_images=rest_images
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment