晚上好!我一直试图在PIL中制作一个脚本,在另一个图像后面粘贴一个图像,比如一个模因模板。问题是-我找不到办法把它放到后面一层。在这里,我将提供示例,说明我希望它输出和它所做的
我想要它输出的东西:

它的产出:

下面是我用来生成底部图像的代码:
url = ctx.message.attachments[0].url # Getting the image from Discord
pic = requests.get(url, stream=True).raw # Putting that image into the pic variable
template = Image.open("./generators/scott.png") # Opening the template with Scott into PIL
pic = Image.open(pic) # Opening the image from Discord
pic = pic.resize((565,402)) # Resizing the image to the size of the TV screen
template.paste(pic,(200,278)) # Pasting the image where it belongs
template.save("./renderedcontent/scott.png") # Saving the image to send it我尝试过的:
我试着浏览文档中的其他函数,尝试了一些,无法完成它们,尝试使用变量和掩码。什么都没有用,甚至有一些有趣的渲染。
TL;DR:
我需要粘贴图像到后面的一层,这样它就会在大的png模板后面。
发布于 2021-06-18 00:31:54
如果你不介意透视的话,我能思考的最快的方法是:
上的大图像。
https://stackoverflow.com/questions/67923281
复制相似问题