Pillow制作斜体字水印

栏目: Html · 发布时间: 6年前

im = Image.open('my_pic.png')

    w, h = im.size

    watermark = Image.new('RGBA', im.size) # 水印

    draw = ImageDraw.Draw(watermark, 'RGBA')

    font_size = 10
    # 的哥是字体
    font = ImageFont.truetype(font='思源宋体TC-Regular.otf', size=font_size, layout_engine=ImageFont.LAYOUT_RAQM)

    # x y 坐标
    draw.text((0, 0), '这是水印内容', font=font, fill="#ff0000")
    # 旋转45度 
    watermark = watermark.rotate(-45, Image.BICUBIC)
    # 透明的
    alpha = watermark.split()[3]
    alpha = ImageEnhance.Brightness(alpha).enhance(0.7)
    watermark.putalpha(alpha)

    # 合成新的图片
    n = Image.composite(watermark, im, watermark)
    n.save('new_watermark.png', 'PNG')

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Complexity and Approximation

Complexity and Approximation

G. Ausiello、P. Crescenzi、V. Kann、Marchetti-sp、Giorgio Gambosi、Alberto M. Spaccamela / Springer / 2003-02 / USD 74.95

This book is an up-to-date documentation of the state of the art in combinatorial optimization, presenting approximate solutions of virtually all relevant classes of NP-hard optimization problems. The......一起来看看 《Complexity and Approximation》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具