给图片(微信头像)右下角添加中国国旗

from __future__ import print_function
from PIL import Image

"""
需求:给图片右下角添加中国国旗
欢迎国庆,喜庆70周年
"""


class Picture:
    def handle_picture(self):
        # 打开图片模版
        img1 = Image.open("icon.png")
        # img1 = img1.convert('RGBA')
        # 打开原来的微信头像
        img2 = Image.open("test.jpg")

        if img2.size != (700, 700):  # 判断图片大小,统一改为 700*700
            # 修改图片尺寸
            size = (700, 700)
            img2.thumbnail(size)
            img2.show()
        # 将img1 粘贴到 img2
        img2.paste(img1, (532, 526))
        img2.show()   # 显示图片
        img2.save("new.png")   # 保存生成的头像图片


t0 = Picture()
t0.handle_picture()
prolove 的头像
  • b853

  • 9388

  • bc41

  • 0128

  • e36e

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Insert the contact form shortcode with the additional CSS class- "bloghoot-newsletter-section"

By signing up, you agree to the our terms and our Privacy Policy agreement.