代码:
from PIL import Image, ImageDraw
import requests
img = Image.new('RGBA', (500, 500), 'black')
canvas = ImageDraw.Draw(img)
logo = Image.open(requests.get('https://api-assets.clashofclans.com/badges/70/-1w_sJci3z0Z8XYk-PT9vDhgJzmgzrhdxPbKAUD298s.png', stream=True).raw)
img.paste(logo.convert('RGBA'))
img.show()
结果是这样的
如何使粘贴的图像完全融合?
我想将粘贴的图像完全整合
只需将
'black'
更改为 (0, 0, 0, 0)
from PIL import Image, ImageDraw
import requests
img = Image.new('RGBA', (500, 500), (0, 0, 0, 0))
canvas = ImageDraw.Draw(img)
logo = Image.open(requests.get('https://api-assets.clashofclans.com/badges/70/-1w_sJci3z0Z8XYk-PT9vDhgJzmgzrhdxPbKAUD298s.png', stream=True).raw)
img.paste(logo.convert('RGBA'))
img.show()
from PIL import Image, ImageDraw
import requests
img = Image.new('RGBA', (500, 500), 'black')
canvas = ImageDraw.Draw(img)
logo = Image.open(requests.get('https://api-assets.clashofclans.com/badges/70/-1w_sJci3z0Z8XYk-PT9vDhgJzmgzrhdxPbKAUD298s.png', stream=True).raw)
img.paste(logo.convert('RGBA'), (0, 0), logo.convert('RGBA')) # (0, 0) is position
img.show()