-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagedealer.py
27 lines (20 loc) · 1.02 KB
/
imagedealer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from PIL import ImageFont
class Marker:
def marker(self, filepath, extra_func, name, font_size, f_color) :
from PIL import Image, ImageDraw, ImageTk
# get an image
with Image.open( filepath ).convert( "RGBA" ) as base :
# make a blank image for the text, initialized to transparent text color
txt = Image.new( "RGBA", base.size, (255, 255, 255, 0) )
# get a fon"arial
fnt = ImageFont.truetype( "arial.ttf", font_size )
# get a drawing context
d = ImageDraw.Draw( txt )
# getting base image size
base_height = base.size[1]
# draw text, half opacity
d.text( (10, base_height - 60), "Created By", font=fnt, fill=(f_color[0], f_color[0], f_color[0], 128) )
# draw text, full opacity
d.text( (10, base_height - 30), name, font=fnt, fill=(f_color[0], f_color[0], f_color[0], 255) )
out = Image.alpha_composite( base, txt )
extra_func( out, name )