Created
June 15, 2019 20:02
-
-
Save rostegg/ce26f79e65d41c720c2b96f74f2bdec7 to your computer and use it in GitHub Desktop.
Build PDF from images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fpdf import FPDF | |
| from PIL import Image | |
| PATH = 'images/' | |
| files = [PATH + f for f in listdir(PATH) if isfile(join(PATH, f))] | |
| # format - widt&heigh of images | |
| pdf = FPDF(unit="pt", format=[1600, 2400]) | |
| for f in files: | |
| pdf.add_page() | |
| pdf.image(f, 0, 0) | |
| pdf.output("output.pdf", "F") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment