Mercurial > repos > ghero
changeset 8:a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 03 Sep 2013 09:49:29 -0700 |
parents | 4ffd621f1d0c |
children | 997690aa0507 |
files | img2tiles.py |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/img2tiles.py Tue Sep 03 09:37:53 2013 -0700 +++ b/img2tiles.py Tue Sep 03 09:49:29 2013 -0700 @@ -212,8 +212,18 @@ print "Not enough arguments" return fname = argv[1] + static_colors = 8 + dynamic_colors = 8 + if len(argv) > 3: + static_colors = int(argv[3]) + dynamic_colors = min(dynamic_colors, 16-static_colors) + if len(argv) > 4: + dynamic_colors = int(argv[4]) + if dynamic_colors + static_colors > 16: + print "No more than 16 combined dynamic and static colors are allowed" + return im = Image.open(fname) - pal = make_palette(im, threshold, 8, 8) + pal = make_palette(im, threshold, static_colors, dynamic_colors) palpix = trans_image(im, threshold, pal) tiles = to_tiles(palpix) bits = add_pal_entries(tiles, pal)