forked from 0x2620/oxjs
update geo module
This commit is contained in:
parent
2b394ca28b
commit
e0d4dd3bec
1619 changed files with 6021 additions and 686370 deletions
43
tools/geo/py/png.py
Normal file
43
tools/geo/py/png.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import Image
|
||||
import json
|
||||
import os
|
||||
|
||||
svg_path = '../svg/icons/'
|
||||
png_path = '../png/icons/4096/'
|
||||
|
||||
for file in os.listdir(svg_path):
|
||||
svg_file = svg_path + file
|
||||
print svg_file
|
||||
if svg_file[-4:] == '.svg' and not os.path.islink(svg_file):
|
||||
tmp_file = png_path + file + '.png'
|
||||
png_file = tmp_file.replace('.svg.png', '.png')
|
||||
if not os.path.exists(png_file):
|
||||
os.system('qlmanage -t -s 4096 -o ' + png_path + ' ' + svg_file)
|
||||
while not os.path.exists(tmp_file):
|
||||
pass
|
||||
os.rename(tmp_file, png_file)
|
||||
image = Image.open(png_file)
|
||||
for size in [1024, 256, 64, 16]:
|
||||
image = image.resize((size, size), Image.ANTIALIAS)
|
||||
image.save(png_file.replace('/4096/', '/%d/' % size))
|
||||
|
||||
for file in os.listdir('../png/flags/'):
|
||||
if file[-4:] == '.png':
|
||||
country = file[:-4]
|
||||
png_file = png_path + country + '.png'
|
||||
print png_file
|
||||
image = Image.open(png_file)
|
||||
# include 4096 to overwrite manually generated image
|
||||
for size in [4096, 1024, 256, 64, 16]:
|
||||
image = image.resize((size, size), Image.ANTIALIAS)
|
||||
image.save(png_file.replace('/4096/', '/%d/' % size))
|
||||
|
||||
image = Image.new('RGB', (1152,1152))
|
||||
f = open('../json/countries.json')
|
||||
countries = json.loads(f.read())
|
||||
f.close()
|
||||
for i, country in enumerate(countries):
|
||||
file = png_path.replace('/4096/', '/64/') + country['code'] + '.png'
|
||||
if os.path.exists(file):
|
||||
image.paste(Image.open(file), (i % 18 * 64, int(i / 18) * 64))
|
||||
image.save('../png/icons.png')
|
||||
Loading…
Add table
Add a link
Reference in a new issue