-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.py
24 lines (22 loc) · 860 Bytes
/
convert.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
import glob, os, sys
from pdf2image import convert_from_path, convert_from_bytes
from PIL import Image, ImageFile
path = "./export"
root = [f for f in os.listdir(path) if not f.startswith('.')]
for folder in root:
currentPath = path + "/" + folder
print ("current folder: " + currentPath)
#print os.listdir(currentPath)
for file in os.listdir(currentPath):
if file.endswith(".pdf"):
currentPDFFile = os.path.join(currentPath, file)
print(currentPDFFile)
currentPage = 1
for jpegs in convert_from_path(currentPDFFile):
saveTo = '.' + str(currentPDFFile).split('.')[1] + "-" + str(currentPage).zfill(2) + ".jpeg"
jpegs.save(saveTo, format='JPEG', quality=100)
print(saveTo)
currentPage += 1
print
print
print