Skip to content

Instantly share code, notes, and snippets.

@doggan
Created July 20, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doggan/d7f75a912376409f80ab1cb047ea6d99 to your computer and use it in GitHub Desktop.
Save doggan/d7f75a912376409f80ab1cb047ea6d99 to your computer and use it in GitHub Desktop.
#!/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