-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstitcher.py
44 lines (29 loc) · 953 Bytes
/
stitcher.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
42
43
44
import os
from PIL import Image
#import time
import shutil
mangas = os.listdir("temp")
if not os.path.exists("downloads"):
os.mkdir("downloads")
for manga in mangas:
if not os.path.isdir(f"temp/{manga}"):
print(f"Skipping {manga} since its not a directory")
continue
images = []
print("processing manga: " + manga)
imagefiles = os.listdir(f"temp/{manga}")
imagelen = len(imagefiles)
print("Done! Beggining to append to pdf...")
for i in range(1, imagelen + 1):
print("Opening image " + str(i))
try:
images.append(Image.open(f"temp/{manga}/{i}.png"))
except:
# apples fucking retarded DS_Store file
continue
pdf_path = f"downloads/{manga}.pdf"
print("Saving to pdf ")
images[0].save(
pdf_path, "PDF" ,resolution=100.0, save_all=True, append_images=images[1:]
)
shutil.rmtree(f"temp/{manga}")