~vono22/narau/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python

import os
import sys
import subprocess

DIRS=['drawable-ldpi', 'drawable-mdpi', 'drawable-hdpi', 'drawable-xhdpi']
RES=[36, 48, 72, 96]
for i in range(len(DIRS)):
	d_dir = DIRS[i]
	res = str(RES[i])

	start_files_args = 1
	if len(sys.argv) >= 3 and sys.argv[1] == '-s':
		d_dir = d_dir + '-' + sys.argv[2]
		start_files_args = 3
	if len(sys.argv) > start_files_args:
		files = sys.argv[start_files_args:]
	else:
		files = os.listdir('.')

	print('Gen png for ' + d_dir + ' (' + res + 'x' + res + ')...')
	subprocess.call(['/bin/mkdir', '-p', d_dir])
	for svg in files:
		if len(svg) > 4 and svg[-4:] == '.svg':
			png=d_dir + '/' + svg[:-4] + '.png'
			subprocess.call(['/usr/bin/inkscape', '-z', '-C', svg, '-e', png, '-w', res, '-h', res])
			trimage = subprocess.Popen(['/usr/bin/trimage', '-f', png])

trimage.wait()