如何将多个图片合并成一长条

本文介绍了一种使用Python编程语言将多张图片合并成一张长图的方法,通过示例代码展示了实现过程。
摘要由CSDN通过智能技术生成

直接上代码

# -*- 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)
      
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值