-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogo.py
More file actions
50 lines (44 loc) · 1.37 KB
/
Copy pathlogo.py
File metadata and controls
50 lines (44 loc) · 1.37 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# coding: utf-8
import os
from Tkinter import *
from tkFileDialog import askopenfilename
import PIL
from PIL import ImageOps
DIRECTORY = # directory for all logos e.g. "/Users/user/desktop/logos/"
def create_folder():
directory = DIRECTORY + officeName.get()
print directory
try:
os.makedirs(directory)
except OSError:
pass
master.quit()
master = Tk()
Label(master, text="Name of Office").grid(row=0)
Label(master, text="Fill Color").grid(row=1)
officeName = Entry(master)
officeName.grid(row=0, column=1)
color = Entry(master)
color.grid(row=1, column=1)
Button(master, text='Create', command=create_folder).grid(row=3, column=1, sticky=W, pady=4)
mainloop()
filename = askopenfilename()
print filename
if not color.get():
color = "#FFFFFF"
else:
color = "#" + color.get()
print color
img = PIL.Image.open(filename)
wpercent = (600 / float(img.size[0]))
hsize = int((float(img.size[1]) * float(wpercent)))
img = img.resize((600, hsize), PIL.Image.ANTIALIAS)
img.save(DIRECTORY + officeName.get() + "/logo600.png")
img = PIL.Image.open(filename)
hpercent = (100 / float(img.size[1]))
wsize = int((float(img.size[0]) * float(hpercent)))
img = img.resize((wsize, 100), PIL.Image.ANTIALIAS)
w = (int(640 - img.size[0])/2)
img = ImageOps.expand(img, border = w, fill = color)
img = ImageOps.fit(img, (640, 100), 0, 0, (0.5,0.5))
img.save(DIRECTORY + officeName.get() + "/logo640x100.png")