1 from PIL import Image 2 img1 = Image.open(r'C:\Users\87823\Desktop\tree.png') 3 img2 = Image.open(r'C:\Users\87823\Desktop\gold.png') 4 img2 = img2.resize(img1.size) #尺寸要相同 5 r,g,b = img1.split() # 分隔通道 6 Image.composite(img1,img2,b).show()
2024-03-24 17:05:40
1 from PIL import Image 2 img1 = Image.open(r'C:\Users\87823\Desktop\tree.png') 3 img2 = Image.open(r'C:\Users\87823\Desktop\gold.png') 4 img2 = img2.resize(img1.size) #尺寸要相同 5 r,g,b = img1.split() # 分隔通道 6 Image.composite(img1,img2,b).show()