Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Created April 6, 2017 15:21
Show Gist options
  • Save RobinDavid/2c376bcfa6bebd74f37d2492b8cb218a to your computer and use it in GitHub Desktop.
Save RobinDavid/2c376bcfa6bebd74f37d2492b8cb218a to your computer and use it in GitHub Desktop.
Create a pdf from a set of jpg images
from fpdf import FPDF
from path import Path
import sys
imagelist = [x for x in sorted(Path(sys.argv[1]).listdir()) if x.ext == ".jpg"]
pdf = FPDF()
for im in imagelist:
pdf.add_page(orientation="P", format=(410,550)) #Size of images is known
pdf.image(im, 0, 0, 410, 550)
pdf.output("output.pdf","F")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment