直接上代码
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 14 20:17:34 2020
@author: 15111
"""
"""
import os
from PIL import Image
import random
all_path = []
heights = []
widths= []
heightss = []
num = 0
url = r'C:\Users\15111\Desktop\AA\\'
def getfile(url0):
ros_listdirs = os.listdir(url0)
ros_listdirs.sort(key=lambda x:int(x[-6:-4]))#sort函数的用法
for filename in ros_listdirs:
if filename.endswith('jpg') or filename.endswith('png'):
all_path.append(os.path.join(url0, filename))
for each in all_path:
pic_fole_head = Image.open(each)
width, height = pic_fole_head.size
heights.append(height)
widths.append(width)
w = max(widths)
h = sum(heights)
toImage = Image.new('RGBA', (w, h))
for each in all_path:
pic_fole_head = Image.open(each)