Python: 使用拼接两张图片,输出为一张
生活随笔
收集整理的這篇文章主要介紹了
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,ImageFontdef hebing():imgtop = Image.open("C:\\Users\\admin\\Desktop\\1\\temp\\1.0.JPG") #圖片1路徑for i in range(46):i=i+1print(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()
總結
以上是生活随笔為你收集整理的Python: 使用拼接两张图片,输出为一张的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序推送功能最新版本(推送到服务通
- 下一篇: 理解CAS操作