-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
21 lines (17 loc) · 658 Bytes
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
from PIL import Image
def ReadDirList(ImageFolder):
"""Read the directory list of the image folder and sort it"""
DirList = os.listdir(ImageFolder)
DirList.sort()
return DirList
def Img2PDF(ImageFolder, PDFName):
"""Convert images in the image folder to PDF
ImageFolder: Image folder path
PDFName: PDF file name"""
image = [ Image.open(f"{ImageFolder}/" + str(f)) for f in ReadDirList(ImageFolder)]
image[0].save(f"{PDFName}.pdf", "PDF",resolution=100.0, save_all=True, append_images=image[1:])
if __name__ == "__main__":
ImageFolder = "Image"
PDFName = "Kratos.pdf"
Img2PDF(ImageFolder, PDFName)