compositeメソッドで2枚の画像をマスク画像を使用して合成する。
from PIL import Image
img1 = Image.open('aoi-chan_gray.png')
img2 = Image.open('gaming.png').resize(img1.size)
mask = Image.new("L", img1.size, 50)
img = Image.composite(img1, img2, mask)
img.save('aoi-chan.png_gaming.png')
元の画像①
![](https://www.miraiportal.com/wp-content/uploads/2023/07/aoi-chan.png)
元の画像②
![](https://www.miraiportal.com/wp-content/uploads/2023/07/gaming.png)
合成した画像
![](https://www.miraiportal.com/wp-content/uploads/2023/07/aoi-chan_gaming.png)
参考
![](https://raw.githubusercontent.com/python-pillow/pillow-logo/main/pillow-logo-dark-text-1280x640.png)
Image Module
The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a ...