# HG changeset patch # User Mike Pavone # Date 1378226969 25200 # Node ID a049de420cc16318198bb53060a827cda07d60b0 # Parent 4ffd621f1d0c311b3338814a8c8609c2714775a5 Make number of static and dynamic colors command line arguments to img2tiles.py diff -r 4ffd621f1d0c -r a049de420cc1 img2tiles.py --- 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)