520画一张心爱的人的图吧
成品
import PIL
from PIL import Image, ImageDraw, ImageFont
import cv2
def draw(pic, draw_text):
img = cv2.imread(pic)
blank = Image.new("RGB",[img.shape[1], img.shape[0]], "white")
drawObj = ImageDraw.Draw(blank)
n = 10
m = 9 # 字体的大小
font_path ='C:\Windows\Fonts\Arial.ttf'
font = ImageFont.truetype(font_path,size = m)
for i in range(0, img.shape[0], n):
for j in range(0, img.shape[1], n):
drawObj.text(
[j, i],
draw_text[int(j / n) % len(draw_text)],
fill = (img[i][j][2], img[i][j][1],
img[i][j][0]),
font = font
)
blank.save('img_VC.jpg')
draw('D:\MyCode\SS.jpg', "520")
网友评论