-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerchify.py
More file actions
23 lines (19 loc) · 791 Bytes
/
Copy pathmerchify.py
File metadata and controls
23 lines (19 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from PIL import Image, ImageDraw
def run(width, height, inputDirectory, outputDirectory):
for filename in os.listdir(inputDirectory):
# get file
art = Image.open(inputDirectory + '/' + filename)
# resize file if necessary
artW, artH = art.size
halfWidth = width/2
if(artW < halfWidth):
art = art.resize((int(halfWidth),int(halfWidth/artW*artH)))
else:
print ("didn't need resizing")
artW, artH = art.size
# create blank shirt and paste art
shirt = Image.new('RGBA',(width, height))
shirt.paste(art, (int((width-artW)/2),int((height-artH)/10)))
# save shirt
shirt.save(outputDirectory + '/' + os.path.splitext(filename)[0] + '_shirt.png', 'png')