专栏导读

-
🌸 欢迎来到Python办公自动化专栏—Python处理办公问题,解放您的双手
-
-
-
-
📕 此外还有python基础专栏:请点击——>Python基础学习专栏求订阅
-
文章作者技术和水平有限,如果文中出现错误,希望大家能指正🙏
-
❤️ 欢迎各位佬关注! ❤️
库的介绍
-
Python 可以使用 PIL(Python Imaging Library,现在通常称为 Pillow)库,实现非常多的功能,如下:
-
1、图片裁剪
-
2、图片添加文字
-
3、图片合成
-
4、图片增加、减少亮度
-
5、截图
库的安装
pip install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple/
1、水平合成(并排)


from PIL import Image
img1 = Image.open('image1.jpg')
img2 = Image.open('image2.jpg')
width = img1.width + img2.width
height = img1.height
new_img = Image.new('RGB', (width, height))
new_img.paste(img1, (0, 0))
new_img.paste(img2, (img1.width, 0))
new_img.save('combined_horizontal.jpg')

2、水平合成(并排) 多张合并
'''
@Project :测试
@File :合并.py
@IDE :PyCharm
@Author :一晌小贪欢(278865463@qq.com)
@Date :2024/6/30 21:01
'''
import os
from PIL import Image
image_list = []
for i in range(len(os.listdir('image'))):
image_list.append(Image.open('image/' + os.listdir('image')[i]))