我已经在背景上粘贴了一个图像,但我目前面临一个问题,我不知道如何使粘贴图像的角变圆。我想对保存在下面脚本中的用户变量中的图像进行四舍五入
import io, requests
from PIL import Image
user = Image.open(io.BytesIO(requests.get('https://cdn.discordapp.com/attachments/710929396013334608/720738818667446282/65578836_2994649093913191_1181627229703939865_n.jpg').content)).resize((40, 40))
back = Image.new('RGB', (646, 85), (54, 57, 63))
byteImg = io.BytesIO()
back.save(byteImg, format='PNG', quality=95)
back = Image.open(io.BytesIO(byteImg.getvalue()))
back.paste(user, (15, 23))
back.save('done.png') # Should save to the current directory
我学会了如何创作图像。我们能够创建并合成一个面具图像
Image.composite
来自PIL
库。我引用了Composite two images according to a mask image with Python, Pillow这篇文章相关问题 更多 >
编程相关推荐