这里是简单的实现代码
实际是用python写的哈哈哈q(≧▽≦q)
import cv2
from PIL import ImageFont, ImageDraw, Image
import numpy as np
bk_img = cv2.imread("gaokao2.jpg")
fontpath = "font/simsun.ttc"
font = ImageFont.truetype(fontpath, 40)
text = "看啊"
box = font.getbbox(text)
text_width=box[3]-box[1]
text_height=box[2]-box[0]
x = ((700 + text_width) // 2)
y =((1000 - text_height) // 20)
img_pil = Image.fromarray(bk_img)
draw = ImageDraw.Draw(img_pil)
draw.text((x,y+text_width*1+10), "做一题会一题", font = font, fill = (255, 255,255))
draw.text((x,y+text_width*2+20), " 分数往上提!", font = font, fill = (255, 255, 255))
draw.text((x,y+text_width*3+30), "多一分升一名", font = font, fill = (255, 255, 255))
draw.text((x,y+text_width*4+40), " 圆梦高考赢!", font = font, fill = (255, 255, 255))
draw.text((x,750+text_width*5+50), " 马到成功!", font = font, fill = (255, 255, 255))
draw.text((x,750+text_width*6+60), " 拨云见日!", font = font, fill = (255, 255, 255))
draw.text((x,750+text_width*7+70), " 高考必胜!", font = font, fill = (255, 255, 255))
bk_img = np.array(img_pil)
cv2.imshow("add_text",bk_img)
cv2.waitKey()
cv2.imwrite("add_text.jpg",bk_img)
就这样,别看了!
简单点就去练习批图吧
批完这个图花不了两分钟哒
就这样,TIME!