我是靠谱客的博主 寒冷鞋子,这篇文章主要介绍python-图片纵向拼接,现在分享给大家,希望可以做个参考。

import 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)
if __name__ == '__main__':
pinjie()

拼接效果图:


最后

以上就是寒冷鞋子最近收集整理的关于python-图片纵向拼接的全部内容,更多相关python-图片纵向拼接内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部