-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpineapple.py
More file actions
53 lines (43 loc) · 1.22 KB
/
Copy pathpineapple.py
File metadata and controls
53 lines (43 loc) · 1.22 KB
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
import sys
import os
from PIL import Image
import glob
name_prefix = ""
start = 1
cat = []
cat.append((2,2))
#cat.append(())
#cat.append((2,2))
def pic_concat(pics, out_name):
images = [Image.open(x) for x in pics]
widths, heights = zip(*(i.size for i in images))
max_width = max(widths)
total_height = sum(heights)
new_im = Image.new('RGB', (max_width, total_height), color="white")
y_offset = 0
for im in images:
new_im.paste(im, (0,y_offset))
y_offset += im.size[1]
new_im.save(out_name)
for pic in pics:
os.system("rm %s"%pic)
def main():
pics = sorted(glob.glob("*.png"))
i,j = 0, 0
cnt = start
while i < len(pics):
if j < len(cat) and cnt == cat[j][0]:
#cat
cat_pics = []
for k in range(cat[j][1]):
os.system('mv "%s" %s%04d-%d.png'%(pics[i],name_prefix, cnt, k))
cat_pics.append("%s%04d-%d.png"%(name_prefix,cnt,k))
i += 1
pic_concat(cat_pics,"%s%04d.png"%(name_prefix,cnt))
j += 1
cnt += 1
else:
os.system('mv "%s" %s%04d.png'%(pics[i],name_prefix,cnt))
i += 1
cnt += 1
main()