Skip to content

Commit 9f87467

Browse files
committed
Create 0000.py
1 parent 4a36ee5 commit 9f87467

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

razzl/0000/0000.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
3+
'''
4+
Draw a number on the image
5+
'''
6+
7+
try:
8+
from PIL import Image
9+
from PIL import ImageDraw
10+
from PIL import ImageFont
11+
except ImportError:
12+
import Image,ImageFont,ImageDraw
13+
14+
def draw_number(path = '/root/Desktop/1.jpg',num = 4):
15+
im = Image.open(path)#open the picture
16+
size = im.size#get the size of the picture
17+
fontsize = size[0]/4a
18+
draw = ImageDraw.Draw(im)#the ImageDraw.Draw will rerturn a object then you can draw it
19+
font = ImageFont.truetype('/usr/share/fonts/dejavu/DejVuSans.ttf',size[0]/4)#define the font and sieze of the number
20+
draw.text((3*fontsize,0),str(num),(255, 0, 0),font)#draw it
21+
im.save('/root/Desktop/2.jpg')#save
22+
draw_number()

0 commit comments

Comments
 (0)