栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python: 使用拼接两张图片,输出为一张

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python: 使用拼接两张图片,输出为一张

# -*- coding: gbk -*-
# 2022/1/4
# PyCharm
# author='曹家伟',
# author_email='studyss@qq.com',
# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名
# pip --default-timeout=100 install -U 库名
# 拼接两张图片使用
from PIL import Image, ImageDraw,ImageFont

def hebing():
    imgtop = Image.open("C:\Users\admin\Desktop\1\temp\1.0.JPG")     #图片1路径
    for i in range(46):
        i=i+1
        print(i)
        file_in = 'C:\Users\admin\Desktop\1\temp\yun\' + str(i) + '.0.JPG'
        imglow=Image.open(file_in)
        file_out = 'C:\Users\admin\Desktop\1\temp\img\' + str(i) + '.0.JPG'
        rrr=Image.new('RGB',(3453,4122),(255,255,255))    #创建的新图的宽和高
        rrr.paste(imgtop,(0,0))           #从0,0开始贴图
        rrr.paste(imglow,(0,500))          #从0,500开始贴图     贴图高度根据第一个图高度判断
        rrr.save(file_out)       #合成后图片所放路径
if __name__ == '__main__':
    hebing()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/767397.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号