This repository has been archived by the owner on Jun 9, 2018. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Framer/framer.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61 lines (44 sloc)
1.55 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]) |