import cv2 from PIL import Image import numpy as np from PIL import Image, ImageDraw, ImageFont def self_adaption_font_oneline(font_filename, default_font_size, text): ttfont = ImageFont.truetype(font_filename, default_font_size) w, h = ttfont.getsize(text) return ttfont,w,h def generate_chart(): text = u'美食,欢迎大家品尝' font_filename = "fonts/李旭科书法.ttf" font_size = 40 font_color = (255,0,0) #font_color = "hsl(0, 100%, 50%)" PIL把HSL参数变成RGB参数值
https://hhsprings.bitbucket.io/docs/programming/examples/python/PIL/ImageColor.htmlttfont, font_width, font_height = self_adaption_font_oneline(font_filename, font_size, text) buffer = 0
PIL python 图形大小随文字变化
最新推荐文章于 2024-06-01 17:12:28 发布