你好用枕头在图片上写文字并不清楚。 什么是ploblem?我想要明确的文字。
这是我的代码。 它的作品是在背景图像上撰写文字。 但结果是没有明确的文字...... 我看到100%大小的test.jpg。 但附近的文字是photoshop溶解效果..
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import os
import subprocess
FRSCRIPT_30 = ImageFont.truetype("C:/Windows/Fonts/FRSCRIPT.TTF", 30)
dejavusans_font_s = ImageFont.truetype("C:/Windows/Fonts/dejaVuSans.ttf", 8)
ENCOSCPT_15 = ImageFont.truetype("C:/Windows/Fonts/ENCOSCPT.TTF", 15)
trajanpro3_font_10 = ImageFont.truetype("C:/Windows/Fonts/TrajanPro3-Regular.otf", 10)
background = Image.new("RGBA", (650,300), (255,255,255))
background.save(os.getcwd() + 'test.jpg')
draw = ImageDraw.Draw(background)
draw.text((20,30), "Pillow and PIL cannot co-exist in the same environment.", fill = (149,149,149), font=FRSCRIPT_30)
draw.text((20,70), "Pillow and PIL cannot co-exist in the same environment.", fill = (149,149,149), font=dejavusans_font_s)
draw.text((20,80), "Pillow and PIL cannot co-exist in the same environment.", fill = (149,149,149), font=ENCOSCPT_15)
draw.text((20,100), "Pillow and PIL cannot co-exist in the same environment.", fill = (149,149,149), font=trajanpro3_font_10)
draw.text((20,110), "Pillow and PIL cannot co-exist in the same environment.", fill = (200, 200, 200), font=ENCOSCPT_15)
draw.text((20,120), "Pillow and PIL cannot co-exist in the same environment.", fill = (170,170,170), font=ENCOSCPT_15)
draw.text((20,130), "Pillow and PIL cannot co-exist in the same environment.", fill = (190,190, 190), font=ENCOSCPT_15)
draw.text((20,200), "Pillow Pillow Pillow Pillow Pillow Pillow.", (149,149,149), font=trajanpro3_font_10)
background.save(os.getcwd() + 'test.jpg')
subprocess.call([os.getcwd() + 'test.jpg'], shell=True)