-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphotoInvite.py
More file actions
21 lines (20 loc) · 897 Bytes
/
photoInvite.py
File metadata and controls
21 lines (20 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! python3
# create custom photo invites using a lost of photos
import os
from PIL import Image, ImageDraw, ImageFont
guestFile = open('guests.txt', 'r')
guests = guestFile.readlines()
flowerIm = Image.open('flower.jpg').convert('RGBA')
flowerIm = flowerIm.resize((200, 200))
flowerWidth, flowerHeight = flowerIm.size
for name in guests:
print('creating invite...')
im = Image.new('RGBA', (300, 360), 'black')
imHeight, imWidth = im.size
draw = ImageDraw.Draw(im)
fontsFolder = 'C:\\Windows\\Fonts'
arialFont = ImageFont.truetype(os.path.join(fontsFolder, 'arial.ttf'), 12)
draw.text((50, 50), 'dear '+name.strip('\n')+' you are invited to our party', fill='gray', font=arialFont)
im.paste(flowerIm, (70, 150), flowerIm)
print('saving %s\'s invite...' % name.strip('\n'))
im.save(os.path.join('imgur', '%s_Invite.png'%name.strip('\n')))