Skip to content

Commit 55fb8cf

Browse files
committed
Merge pull request Show-Me-the-Code#93 from Iulujianjie/master
Hello,I want to join in this program.
2 parents 215720b + 44d2b0d commit 55fb8cf

File tree

7 files changed

+17
-0
lines changed

7 files changed

+17
-0
lines changed

acwong00/0000/Thumbs.db

36.5 KB
Binary file not shown.

acwong00/0000/finnal.jpg

375 Bytes
Loading

agmcs/0000/Thumbs.db

14.5 KB
Binary file not shown.

lulujianjie/0000/0000.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from PIL import Image, ImageDraw, ImageFont
2+
3+
im = Image.open('image.jpg')
4+
w,h = im.size
5+
font_size = h/4
6+
7+
draw = ImageDraw.Draw(im)
8+
fnt = ImageFont.truetype ("Arial.ttf",font_size)
9+
10+
text_w,text_h = draw.textsize("8",font=fnt) # 给定文字message,返回所占像素(width,height)
11+
12+
draw.text((w-text_w,0), "8", fill=(255,0,0), font=fnt)#图片宽度减去字体宽度、要写的字符、颜色、字体
13+
14+
15+
im.save('image_1.jpg')
16+
17+
#reference http://www.cnblogs.com/wei-li/archive/2012/04/19/2456725.html

lulujianjie/0000/Thumbs.db

28 KB
Binary file not shown.

lulujianjie/0000/image.jpg

60.5 KB
Loading

lulujianjie/0000/image_1.jpg

9.63 KB
Loading

0 commit comments

Comments
 (0)