-
Notifications
You must be signed in to change notification settings - Fork 0
/
Img2pdf.py
42 lines (29 loc) · 885 Bytes
/
Img2pdf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# coding: utf-8
import os
import sys
import img2pdf
from PIL import Image
def print_help():
print("usage : plot_folder_path")
def main():
number_of_args=len(sys.argv)
if (number_of_args != 2):
print_help()
exit(-1)
folder=sys.argv[1]
# folder = "/home/luigi/Documents/scripts/test_scripts/py3_scripts/Plots/2020-02-24"
if not os.path.isdir(folder):
print_help()
exit(-1)
imagelist = []
for dirName, subdirList, fileList in os.walk(folder):
fileList.sort()
for i in fileList:
if(i.endswith(".png")):
img = Image.open(dirName+'/'+i)
img = img.convert('RGB')
imagelist.append(img)
imagelist[0].save(folder+'/plots.pdf',save_all=True, append_images=imagelist)
if __name__ == '__main__':
main()