Mercurial > repos > ghero
annotate img2tiles.py @ 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 | a74776d80f95 |
children | 997690aa0507 |
rev | line source |
---|---|
3 | 1 #!/usr/bin/env python |
2 from PIL import Image | |
3 | |
4 def gchannel(Val): | |
5 return (Val >> 4) & 0xE | |
6 | |
7 threshold = 127 | |
8 | |
9 def get_color_info(pixels, rng, threshold, exclude={}): | |
10 gencolors = {} | |
11 A = 255 | |
12 for idx in rng: | |
13 color = pixels[idx] | |
14 if len(color) == 4: | |
15 (R, G, B, A) = color | |
16 else: | |
17 (R, G, B) = color | |
18 if A > threshold: | |
19 gcolor = (gchannel(R), gchannel(G), gchannel(B)) | |
20 if not gcolor in exclude: | |
21 if gcolor in gencolors: | |
22 gencolors[gcolor] += 1 | |
23 else: | |
24 gencolors[gcolor] = 1 | |
25 glist = [(gencolors[color], color) for color in gencolors] | |
26 glist.sort() | |
27 glist.reverse() | |
28 return glist | |
29 | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
30 def get_color_info_error(pixels, rng, threshold, exclude={}): |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
31 gencolors = {} |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
32 A = 255 |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
33 for idx in rng: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
34 color = pixels[idx] |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
35 if len(color) == 4: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
36 (R, G, B, A) = color |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
37 else: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
38 (R, G, B) = color |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
39 if A > threshold: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
40 gcolor = (gchannel(R), gchannel(G), gchannel(B)) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
41 if not gcolor in exclude: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
42 if not gcolor in gencolors: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
43 _,best = best_match(gcolor, (exclude,)) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
44 gencolors[gcolor] = color_dist(gcolor, best) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
45 glist = [(gencolors[color], color) for color in gencolors] |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
46 glist.sort() |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
47 glist.reverse() |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
48 return glist |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
49 |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
50 def get_color_info_both(pixels, rng, threshold, exclude={}): |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
51 gencolors = {} |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
52 A = 255 |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
53 for idx in rng: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
54 color = pixels[idx] |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
55 if len(color) == 4: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
56 (R, G, B, A) = color |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
57 else: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
58 (R, G, B) = color |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
59 if A > threshold: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
60 gcolor = (gchannel(R), gchannel(G), gchannel(B)) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
61 if not gcolor in exclude: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
62 if not gcolor in gencolors: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
63 _,best = best_match(gcolor, (exclude,)) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
64 gencolors[gcolor] = (color_dist(gcolor, best), 1) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
65 else: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
66 (dist, count) = gencolors[gcolor] |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
67 gencolors[gcolor] = (dist, count+1) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
68 glist = [(gencolors[color][0] * gencolors[color][1], color) for color in gencolors] |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
69 glist.sort() |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
70 glist.reverse() |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
71 return glist |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
72 |
3 | 73 def totiles(im, palette): |
74 pass | |
75 | |
76 def make_palette(im, trans_thresh, max_global, max_line): | |
77 pixels = im.getdata() | |
78 (width, height) = im.size | |
79 colors = get_color_info(pixels, xrange(0, height * width), trans_thresh) | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
80 print len(colors), 'distinct 9-bit colors in image' |
3 | 81 glob_pal = {} |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
82 print 'Static Palette:' |
3 | 83 for idx in xrange(0, min(max_global, len(colors))): |
84 (count, color) = colors[idx] | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
85 print str(idx) + ':', color, '(used', count, 'times)' |
3 | 86 glob_pal[color] = idx |
87 line_pals = [] | |
88 if max_global < len(colors): | |
89 for line in xrange(0, height): | |
90 linestart = line * width | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
91 #linecolors = get_color_info(pixels, xrange(linestart, linestart+width), trans_thresh, glob_pal) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
92 #linecolors = get_color_info_error(pixels, xrange(linestart, linestart+width), trans_thresh, glob_pal) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
93 linecolors = get_color_info_both(pixels, xrange(linestart, linestart+width), trans_thresh, glob_pal) |
3 | 94 line_pal = {} |
95 for idx in xrange(0, min(max_line, len(linecolors))): | |
96 (count, color) = linecolors[idx] | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
97 line_pal[color] = idx + max_global |
3 | 98 line_pals.append(line_pal) |
99 return (glob_pal, line_pals, max_global, max_line) | |
100 | |
101 def color_dist(a, b): | |
102 (ra, ga, ba) = a | |
103 (rb, gb, bb) = b | |
104 return (ra-rb)**2 + (ga-gb)**2 + (ba-bb)**2 | |
105 | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
106 def best_match(gpixel, pals): |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
107 bestdist = color_dist((0,0,0), (15, 15, 15)) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
108 bestpalidx = 0 |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
109 bestcolor = (0,0,0) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
110 for i in xrange(0, len(pals)): |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
111 pal = pals[i] |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
112 for cur in pal: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
113 curdist = color_dist(gpixel, cur) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
114 if curdist < bestdist: |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
115 bestdist = curdist |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
116 bestpalidx = pal[cur] |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
117 bestcolor = cur |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
118 return (bestpalidx, bestcolor) |
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
119 |
3 | 120 def trans_image(im, trans_thresh, pal): |
121 (global_pal, line_pals, _, _) = pal | |
122 pixels = im.getdata() | |
123 (width, height) = im.size | |
124 gpixels = [] | |
125 A = 255 | |
126 x = 0 | |
127 y = 0 | |
128 for pixel in pixels: | |
129 if x == width: | |
130 x = 0 | |
131 y += 1 | |
132 if width % 8: | |
133 for i in xrange(0, 8-(width%8)): | |
134 gpixels.append(0) | |
135 if len(pixel) == 4: | |
136 (R, G, B, A) = pixel | |
137 else: | |
138 (R, G, B) = pixel | |
139 if A > trans_thresh: | |
140 gpixel = (gchannel(R), gchannel(G), gchannel(B)) | |
141 if gpixel in global_pal: | |
142 gpixels.append(global_pal[gpixel]) | |
143 elif gpixel in line_pals[y]: | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
144 gpixels.append(line_pals[y][gpixel]) |
3 | 145 else: |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
146 bestpal,color = best_match(gpixel, (global_pal, line_pals[y])) |
3 | 147 gpixels.append(bestpal) |
148 else: | |
149 gpixels.append(0) | |
150 x += 1 | |
151 if width % 8: | |
152 for i in xrange(0, 8-(width%8)): | |
153 gpixels.append(0) | |
154 width += 8-(width%8) | |
155 if height % 8: | |
156 for y in xrange(0, 8-(height%8)): | |
157 for x in xrange(0, width): | |
158 gpixels.append(0) | |
159 height += 8-(height%8) | |
160 | |
161 return (width, height, gpixels) | |
162 | |
163 def appendword(b, word): | |
164 b.append(word >> 8) | |
165 b.append(word & 0xff) | |
166 | |
167 def to_tiles(palpix): | |
168 (width, height, pixels) = palpix | |
169 b = bytearray() | |
170 cwidth = width/8 | |
171 cheight = height/8 | |
172 words = len(pixels)/4 | |
173 appendword(b, words) | |
174 appendword(b, cwidth) | |
175 appendword(b, cheight) | |
176 | |
177 for cy in xrange(0, cheight): | |
178 ystart = cy*8*width | |
179 for cx in xrange(0, cwidth): | |
180 startoff = (cx*8) + ystart | |
181 for row in xrange(0, 8): | |
182 rowoff = startoff + row*width | |
183 for bytecol in xrange(0, 4): | |
184 boff = bytecol * 2 + rowoff | |
185 #print 'boff:', boff, 'len(pixels)', len(pixels), 'cx', cx, 'cy', cy, 'cwidth', cwidth, 'cheight', cheight | |
186 #print 'pixels[boff]:', pixels[boff] | |
187 b.append(pixels[boff] << 4 | pixels[boff+1]) | |
188 return b | |
189 | |
190 def add_pal_entries(tiles, pal): | |
191 (global_pal, line_pals, max_global, max_line) = pal | |
192 pal_list = [(0, 0, 0)] * max_global | |
193 for entry in global_pal: | |
194 pal_list[global_pal[entry]] = entry | |
195 for entry in pal_list: | |
196 (R, G, B) = entry | |
197 tiles.append(B) | |
198 tiles.append(G << 4 | R) | |
199 for line in line_pals: | |
200 pal_list = [(0, 0, 0)] * max_line | |
201 for entry in line: | |
5
a74776d80f95
Fix a bug in selecting the best match color when an exact match is unavailable. Add some more options for choosing a line palette
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
202 pal_list[line[entry]-max_global] = entry |
3 | 203 for entry in pal_list: |
204 (R, G, B) = entry | |
205 tiles.append(B) | |
206 tiles.append(G << 4 | R) | |
207 | |
208 | |
209 | |
210 def main(argv): | |
211 if len(argv) < 3: | |
212 print "Not enough arguments" | |
213 return | |
214 fname = argv[1] | |
8
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
215 static_colors = 8 |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
216 dynamic_colors = 8 |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
217 if len(argv) > 3: |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
218 static_colors = int(argv[3]) |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
219 dynamic_colors = min(dynamic_colors, 16-static_colors) |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
220 if len(argv) > 4: |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
221 dynamic_colors = int(argv[4]) |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
222 if dynamic_colors + static_colors > 16: |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
223 print "No more than 16 combined dynamic and static colors are allowed" |
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
224 return |
3 | 225 im = Image.open(fname) |
8
a049de420cc1
Make number of static and dynamic colors command line arguments to img2tiles.py
Mike Pavone <pavone@retrodev.com>
parents:
5
diff
changeset
|
226 pal = make_palette(im, threshold, static_colors, dynamic_colors) |
3 | 227 palpix = trans_image(im, threshold, pal) |
228 tiles = to_tiles(palpix) | |
229 bits = add_pal_entries(tiles, pal) | |
230 out = open(argv[2], 'wb') | |
231 out.write(tiles) | |
232 | |
233 if __name__ == '__main__': | |
234 import sys | |
235 main(sys.argv) |