there is a big list containing paths to images:
list= ['home/1.png','home/2.png', ...,'home/100.png']
How to combine them sequentially horizontally?
I solved the problem!
list_= ['home/1.png','home/2.png', ...,'home/100.png']
from PIL import Image
images = [Image.open(x) for x in list_]
widths, heights = zip(*(i.size for i in images))
total_width = sum(widths)
max_height = max(heights)
new_im = Image.new('RGB', (total_width, max_height))
x_offset = 0
for im in images:
new_im.paste(im, (x_offset,0))
x_offset += im.size[0]
new_im.save('/test.png')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.