in learning Python's lookup material, you find a collection of other people's Python topics. 0000 of the topics required to add a number in the upper right corner of a picture, the specific content can be clicked Https://github.com/Yixiaohan/show-me-the-code to view.
#功能: Enter the full address of the picture, and then enter the new generated picture name can produce a new number of pictures, where the font file I placed in the code the same folder
#-*-coding:utf-8-*-from
pil import Imagefont
from PIL import
pil import imagedraw
#输入图片的完整路径, open the picture
location = raw_input ("Please input the Location of the image: "
target = raw_input (" Please input the new name of target and you can enter to get the default Nam E: ")
image = Image.open (location)
#获得当前图片的大小, to set the font size
xsize, ysize = image.size Font
= Imagefont.truetype ("Arial.ttf", int (YSIZE/8))
#在图片上添加数字3
draw = Imagedraw.draw (image)
Draw.text ( 0.9*xsize, 0.1*ysize), "3", (255,0,0), font)
#根据输入的命名来设置新图片名字, the default setting is "formerly known as _new", formatted with the same
form = Location.split ( '.') [1]
If target = = "":
new_location = Location.split ('. ') [0]
Image.Save (new_location+ ' _new. ') +form)
Else:
image.save (target+ '. ') +form)
The details of the Imagedraw module can be clicked Http://effbot.org/imagingbook/imagedraw.htm View
and the PIL module can be installed by clicking http:// pillow-cn.readthedocs.org/zh_cn/latest/installation.html View