简体   繁体   English

如何使用Python Pillow / Image将小图像插入照片的一角?

[英]How to insert small image into corner of a photo with Python Pillow/Image?

I'm trying to insert a small 252 x 40 px image in the bottom right hand corner of an image using the Pillow library. 我正在尝试使用Pillow库在图像的右下角插入一个252 x 40 px的小图像。

Currently, this is how I am trying to do it based off the general method for overlaying an image using Pillow/Image: 目前,这是我根据使用枕头/图像叠加图像的一般方法来尝试执行的操作:

back = Image.open("images/background.png")
width, height = back.size
image1 = Image.open("images/picture.png")
width1, height1 = image1.size
image1 = image1.convert("RGBA")
back.paste(image, (width - width1, width - height1), image1)

Doing this fails to overlay the image. 这样做无法覆盖图像。 Any tips or other libraries I should use to accomplish this? 我应该使用任何技巧或其他库来完成此操作吗?

Figured it out. 弄清楚了。

back.paste(image1, (width - width1, height - height1), image2) back.paste(image1,(width-width1,height-height1,image2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM