首页 > 解决方案 > 使用 PIL python 覆盖两个以上的图像

问题描述

嗨,我正在使用以下代码使用 PIL 模块合并多个图像

from PIL import Image

img0 = Image.open("w1.png")
img0 = img0.convert('RGBA')

img1 = Image.open("body.png")
img1 = img1.convert('RGBA')

img0.paste(img1, (0,0), img1)

img0.save('0.png')

img2 = Image.open("0.png")
img2 = img2.convert('RGBA')

img3 = Image.open("d1.png")
img3 = img3.convert('RGBA')

img2.paste(img3, (0,0), img3)

img2.show()

想知道是否有办法可以合并两个以上的图像。我有 8 张图像需要合并。

谢谢你的任何建议。

标签: pythonmergepython-imaging-library

解决方案


would like to know if there is way i can merge more than two images. i have 8 images that i need to merge.

Just... keep paste-ing new images on?

All Image.paste does is merge the parameter image onto the subject, you can keep doing that, and it'll keep merging the new images.


推荐阅读