-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathnewtime.py
More file actions
23 lines (19 loc) · 763 Bytes
/
newtime.py
File metadata and controls
23 lines (19 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import cv2
from PIL import Image, ImageDraw, ImageFont
import numpy as np
import time
def create(number):
img = cv2.imread("xcm.jpg")
im = Image.new("RGB", (805, 100), (254, 254, 254))
dr = ImageDraw.Draw(im)
font = ImageFont.truetype("heiti.ttf", 58)
text = time.strftime("更新于:%Y.%m.%d %H:%M:%S",time.localtime(time.time()+8*3600-30))
dr.text((30, 0), text, (120, 120, 120), font)
img[545: 645, 180: 985, :] = np.array(im)
im = Image.new("RGB", (805, 100), (254, 254, 254))
dr = ImageDraw.Draw(im)
font = ImageFont.truetype("heiti.ttf", 50)
text = str(number) + "的动态行程卡"
dr.text((115, 0), text, (0, 0, 0), font)
img[427: 527, 180: 985, :] = np.array(im)
cv2.imwrite("xcm.jpg", img)