Created
May 28, 2015 00:51
-
-
Save jtrinklein/2d8bb6dbf8ac15daa347 to your computer and use it in GitHub Desktop.
python script for running graphics conversion tools (https://bitbucket.org/revelj/cgb-tools)
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/python | |
import argparse | |
import subprocess | |
import os | |
parser = argparse.ArgumentParser(description="runner for revelj's graphics conversion scripts for CGB.") | |
parser.add_argument('inputFile', metavar='inputFile', type=str, nargs='+', help='image file to process') | |
parser.add_argument('-o','--out-dir', help='output folder (defaults to locaiton of input file)') | |
parser.add_argument('-s','--script-dir', help='location of revelj scripts (defaults to current dir)', default='') | |
args = parser.parse_args() | |
def do(script, scriptArgs): | |
cmd = ' '.join(['python', os.path.join(args.script_dir,script)] + scriptArgs) | |
subprocess.call(cmd, shell=True) | |
def processImage(srcFile): | |
parts = os.path.split(srcFile) | |
outdir = args.out_dir or parts[0] | |
file = parts[1] | |
fbase = file.split('.')[0] | |
print 'Processing file: ' + file | |
prefix = os.path.join(outdir, fbase) | |
tilesFile = prefix + '_tls.gif' | |
mapJsonFile = prefix + '_map.json' | |
mapBinFile = prefix + '_map.bin' | |
attrBinFile = prefix + '_atr.bin' | |
paletteBinFile = prefix + '_pal.bin' | |
tilesBinFile = prefix + '_tls.bin' | |
do('tileset.py', [srcFile, '-o', tilesFile]) | |
do('tilemap.py', [srcFile, tilesFile, '-o', mapJsonFile]) | |
do('make_tmap.py', [mapJsonFile, '-o', mapBinFile]) | |
do('make_amap.py', [mapJsonFile, '-o', attrBinFile]) | |
do('palette.py', [srcFile, '-o', paletteBinFile]) | |
do('pngtoraw.py', [tilesFile, '-o', tilesBinFile]) | |
for file in args.inputFile: | |
processImage(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment