Show-me-the-code No. 0000 Picture top right corner plus number

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.