This repository was archived by the owner on Jun 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathframer.py
More file actions
61 lines (44 loc) 路 1.55 KB
/
Copy pathframer.py
File metadata and controls
61 lines (44 loc) 路 1.55 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
51
52
53
54
55
56
57
58
59
60
61
# framer.py
# Author: Jeremy Mack
# Code Website: TODO
# Company: Pile of Turtles, LLC
# Company Website: http://pileofturtles.com
# Wrapper for framer.jstalk to call it for a set of image files in a given
# directory.
import glob
import os
import lib.argparse as argparse
from subprocess import call
jstalk = "jstalk"
framerJS = "framer.jstalk"
outputFolderName = "framed"
imageExtensions = ('*.jpg', '*.jpeg', '*.png')
script_folder = os.path.dirname(os.path.abspath(__file__))
resources_directory = os.path.join(script_folder, "resources/")
def parse_commandline_arguments():
parser = argparse.ArgumentParser(description=
"""
Wrapper for framer.jstalk to call it for a set of image files in a given
directory.
"""
)
parser.add_argument('directory', metavar='DIRECTORY', type=str, nargs=1,
help='The directory to process')
return parser.parse_args()
def process_directory(directory):
if directory:
print "Getting my frame on."
outputFolder = os.path.join(directory, outputFolderName)
if not os.path.exists(outputFolder):
print "framed folder created"
os.makedirs(outputFolder)
filesProcessed = 0
for imageExtension in imageExtensions:
imageFiles = glob.glob(directory + imageExtension)
for imageFile in imageFiles:
call([jstalk, framerJS, imageFile, resources_directory])
filesProcessed += len(imageFiles)
print "Framed %d images!" % filesProcessed
if __name__ == '__main__':
args = parse_commandline_arguments()
process_directory(args.directory[0])