Skip to content

Commit d781822

Browse files
committed
0000
1 parent eda16be commit d781822

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

houshengandt/0000/0000.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
from PIL import Image, ImageDraw, ImageFont
3+
from random import randint
4+
5+
6+
# s = "3"
7+
# a = Image.open("1.jpg")
8+
# f = ImageFont.truetype("arial.ttf", 40)
9+
# b = ImageDraw.Draw(a)
10+
# b.text((90, 90), s, fill='red', font=f)
11+
# a.save("2.jpg")
12+
13+
14+
15+
16+
def add_num(filename='1.jpg', text='?', size=40, color='red', newname="2.jpg"):
17+
a = Image.open(filename)
18+
print(a.size)
19+
f = ImageFont.truetype("arial.ttf", size)
20+
b = ImageDraw.Draw(a)
21+
x, y = a.size
22+
xy = (x - 40, y - 170)
23+
b.text(xy, text, fill=color, font=f)
24+
a.save(newname)
25+
26+
27+
# add_num(text="3")
28+
29+
for root, dirs, files in os.walk("C:\\Users\\housh\\Desktop\\tx"):
30+
for file in files:
31+
print(type(file))
32+
add_num("C:\\Users\\housh\\Desktop\\tx\\" + file, newname='new' + file)

0 commit comments

Comments
 (0)