You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
623 B
16 lines
623 B
from PIL import Image, ImageDraw, ImageFont
|
|
import os
|
|
|
|
BASE_DIR = '/var/www/projects/lms/'
|
|
PATH = os.path.join(BASE_DIR, 'img_creator/')
|
|
FONT_PATH = os.path.join(BASE_DIR, 'static/fonts/')
|
|
logo = Image.open('/var/www/projects/lms/utils/web_temp_print.png').convert('RGBA')
|
|
img = Image.new('RGBA', logo.size, (255, 255, 255, 000))
|
|
fnt = ImageFont.truetype(os.path.join(FONT_PATH, 'Exo2-Bold-webfont.ttf'), 70)
|
|
d = ImageDraw.Draw(img)
|
|
d.text((1000, 60), 'test', font=fnt, fill=(0, 0, 0))
|
|
out = Image.alpha_composite(logo, img)
|
|
out.show()
|
|
path = os.path.join(PATH, '{0}.png'.format('test'))
|
|
out.save(path)
|
|
f = open(path, 'r')
|
|
|