The No. 0000 question: Add your QQ head (or Weibo avatar) to the top right corner with a red number, similar to the amount of unread information that prompt effect.
Python's PIL library image processing is powerful and easy to use, and after learning it, it's done.
Effect:
How to use: Perform a py, add a red number to the top right corner of the target file logo.jpg the root directory and output to the Output.jpg file in the root directory
0000. In the top right corner of the picture, add a number. py
#!/usr/bin/env python#coding: Utf-8MyPath ="/home/bill/desktop/"Fontpath ="/usr/share/fonts/truetype/ttf-devanagari-fonts/"Inputfile ="Logo.jpg"OutputFile ="Output.jpg"Import Image, Imagefont, Imagedraw#打开图片im = Image.open (MyPath + inputfile) draw = Imagedraw.draw (IM)#根据图片大小确定字体大小fontsize = min (im.size)/4#加文字Font = Imagefont.truetype (Fontpath +' Kalimati.ttf ', FontSize) Draw.text ((im.size[0]-fontsize,0),' 5 ', Font = font, fill = ( the,0,0)) Im.save (MyPath + outputFile,"JPEG")
Show-me-the-code No. 0000 Picture top right corner plus number