首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在PIL中的模板后面粘贴一个小型png?

如何在PIL中的模板后面粘贴一个小型png?
EN

Stack Overflow用户
提问于 2021-06-10 14:32:09
回答 1查看 45关注 0票数 0

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

我想要它输出的东西:

它的产出:

下面是我用来生成底部图像的代码:

代码语言:javascript
复制
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模板后面。

EN

回答 1

Stack Overflow用户

发布于 2021-06-18 00:31:54

如果你不介意透视的话,我能思考的最快的方法是:

  1. 修改大图像模板,使用Photoshop或gimp删除图像的位置,并将其保存为PNG
  2. 粘贴在画布上的模因
  3. 粘贴到画布

上的大图像。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67923281

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档