-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToLongStrip.py
56 lines (46 loc) · 1.38 KB
/
ToLongStrip.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
45
46
47
48
49
50
51
52
53
54
55
56
__author__ = 'alan.francis'
from PIL import Image
import os
import sys
root_folder = '/Volumes/Personal/Media/Manga/girl_the_wild_s/Ch 206/'
split = True
extn = '.png'
if len(sys.argv) > 1:
root_folder = sys.argv[1]
if len(sys.argv) > 2:
split = sys.argv[2]
if not root_folder.endswith(os.path.sep):
root_folder += os.path.sep
def append(opfile, ipfile):
img1 = None
img1size = [0, 0]
if os.path.exists(opfile):
img1 = Image.open(opfile, 'r')
img1size = img1.size
img2 = Image.open(ipfile, 'r')
img2size = img2.size
img_width = img2size[0]
if img1size[0] > 0 and img1size[0] > img2size[0]:
img_width = img1size[0]
img_height = img1size[1] + img2size[1]
new_img = Image.new('RGBA', (img_width, img_height))
if img1 is None:
new_img.paste(img2, (0, 0))
else:
new_img.paste(img1, (0, 0))
new_img.paste(img2, (0, img1size[1]))
new_img.save(opfile)
file_list = []
for root, dirs, files in os.walk(root_folder):
for eachfile in files:
if not str(eachfile).startswith('.'):
file_list.append(os.path.join(root, eachfile))
filenamecount = 1
count = 1
for eachfile in file_list:
if count == 9 and split == True:
count = 1
filenamecount += 1
print('adding', eachfile, '...')
append(root_folder+str(filenamecount)+extn, eachfile)
count += 1