Skip to content

Commit 09b4350

Browse files
committed
commit 0000.py
1 parent 62bdf04 commit 09b4350

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎mio4kon/0000/0000.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from PIL import Image, ImageDraw, ImageFont, ImageFilter
2+
import sys, os, random
3+
4+
num = str(random.randint(1, 99))
5+
imagePath = os.path.join(sys.path[0], 'mio.jpg')
6+
savaPath = os.path.join(sys.path[0], 'mio_dot.jpg')
7+
8+
9+
def add_num(im, wDraw, hDraw):
10+
font = ImageFont.truetype('Arial.ttf', 30)
11+
draw = ImageDraw.Draw(im)
12+
draw.ellipse(
13+
(radioX, radioY, radioX + 30, radioY + 30), fill='red', outline='red')
14+
draw.text((wDraw, hDraw), num, font=font, fill='white')
15+
im.save(savaPath, 'jpeg')
16+
17+
18+
if __name__ == '__main__':
19+
im = Image.open(imagePath)
20+
w, h = im.size
21+
print('Original image size: %sx%s' % (w, h))
22+
wDraw = int(0.8 * w)
23+
hDraw = int(0.01 * h)
24+
radioX = wDraw
25+
radioY = hDraw
26+
print('radioX:', radioX)
27+
print('radioY:', radioY)
28+
add_num(im, wDraw, hDraw)

‎mio4kon/0000/mio.jpg‎

15.7 KB
Loading

‎mio4kon/0000/mio_dot.jpg‎

9.33 KB
Loading

0 commit comments

Comments
 (0)