复制代码
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
28import os from PIL import Image UNIT_SIZE = 220 # the size of image save_path = '/root/……cyclegan_6.0/web/result3/' path = "/root/……cyclegan_6.0/web/images" images = [] # all pic name def pinjie(): if not os.path.exists(save_path): os.makedirs(save_path) for img in os.listdir(path): images.append(img) for i in range(len(images)/ 6): imagefile = [] j = 0 for j in range(6): imagefile.append(Image.open(path+'/'+images[i*6+j])) target = Image.new('RGB', (UNIT_SIZE, UNIT_SIZE*6)) # width, height left = 0 right = UNIT_SIZE for image in imagefile: target.paste(image, (0, left, UNIT_SIZE, right)) left += UNIT_SIZE right += UNIT_SIZE quality_value = 100 target.save(save_path+'/out_{}.jpg'.format(i), quality=quality_value)
复制代码
1
2if __name__ == '__main__': pinjie()
拼接效果图:
最后
以上就是寒冷鞋子最近收集整理的关于python-图片纵向拼接的全部内容,更多相关python-图片纵向拼接内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复