Created
July 20, 2016 17:17
-
-
Save doggan/d7f75a912376409f80ab1cb047ea6d99 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
""" | |
Pre-processing of emoji images. | |
Requires ImageMagick (mogrify) to be installed and available via CLI. | |
""" | |
import argparse | |
import os | |
import subprocess | |
def parse_args(): | |
parser = argparse.ArgumentParser( | |
description='Preprocessing of emoji assets for use in the app.') | |
parser.add_argument( | |
'source', help='the source image directory') | |
parser.add_argument( | |
'output', help='the output path to write the resultant images') | |
return parser.parse_args() | |
def main(): | |
args = parse_args() | |
output = args.output | |
source = args.source | |
# Prepare the output directory. | |
if not os.path.exists(output): | |
os.makedirs(output) | |
# Build the command. | |
command = [ | |
'mogrify', | |
'-path', | |
output, | |
# Add some padding. | |
'-bordercolor', | |
'transparent', | |
'-border', | |
'1x1', | |
# Resize. | |
'-resize', | |
'32x32', | |
os.path.join(source, '*.png'), | |
] | |
subprocess.call(command) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment