Python image processing Pillow- watermark inserting text or graphics

Attach Code:

#   _*_ coding:utf-8 _*_
__author__ = 'admin'

from PIL import Image, ImageDraw, ImageFont
im =  Image.open(r"linuxidc.com.jpg")
draw = ImageDraw.Draw(im)
myfont = ImageFont.truetype(u"linuxidc.ttf", size=35)
fillcolor = 'red'
draw.text((300, 90), u"Linux公社的文字水印www.linuxidc.com", font=myfont, fill=fillcolor)
im.save(r"www.linuxidc.jpg", 'JPEG')

Original:

Python image processing Pillow- watermark inserting text or graphics

Renderings:

Python image processing Pillow- watermark inserting text or graphics

Let's look at insert graphics, drawing on material other Rotarians, there is also wrote "red dot to remind" it

On the code:

#   _*_ coding:utf-8 _*_
__author__ = 'admin'

from PIL import Image, ImageDraw, ImageFont
im =  Image.open(r"linuxidc.com.png")
draw = ImageDraw.Draw(im)
myfont = ImageFont.truetype('linuxidc.ttf', 60)
width, height = im.size
#   画圆形
draw.ellipse((200,200, 550, 550), fill='red', outline='red')
#   插入文本
draw.text((260, 330), 'Linux公社', font=myfont, fill='white')
im.show()

Renderings:

Python image processing Pillow- watermark inserting text or graphics

(So ​​you can make your own tastes similar picture, anyway, I was aware of the benefits of the Inter each have their own language, only you will be able to apply what they learn it, play well)

(And to all the people interested in learning program because salute!)

Guess you like

Origin www.linuxidc.com/Linux/2020-01/162140.htm