Skip to content

Commit b3b0528

Browse files
committed
Create 0000.py
1 parent 4b72adf commit b3b0528

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

razzl/0000.py

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

0 commit comments

Comments
 (0)