forked from PrincetonCS-UCA/LabQueue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeImages.py
More file actions
27 lines (23 loc) · 871 Bytes
/
MakeImages.py
File metadata and controls
27 lines (23 loc) · 871 Bytes
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
__author__ = 'daifotis'
## THIS IS MEANT AS A LOCAL ONLY SCRIPT
from PIL import Image
import os
MAX_SIDE_PIXELS = 300
for fname in os.listdir("./img/TAs"):
os.remove("./img/TAs/" + fname)
for fname in os.listdir("./img/OriginalTAs"):
if fname.startswith('.'): #ignore hidden files
continue
im = Image.open(os.path.join("./img/OriginalTAs", fname))
width, height = im.size
orig_ratio = float(width) / height
if width >= height:
new_width = MAX_SIDE_PIXELS
new_height = int(float(new_width) / orig_ratio)
else:
new_height = MAX_SIDE_PIXELS
new_width = int(float(orig_ratio) * new_height)
netid = os.path.splitext(fname)[0]
im.resize((new_width, new_height), Image.ANTIALIAS).save("./img/TAs/" + os.path.splitext(fname)[0] + ".jpg")
print "Processed photo...{}".format(fname)
print "Done."