| 1 |
#!/usr/bin/env python |
| 2 |
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net> |
| 3 |
|
| 4 |
|
| 5 |
import os |
| 6 |
import shutil |
| 7 |
import subprocess |
| 8 |
import sys |
| 9 |
|
| 10 |
j = os.path.join |
| 11 |
base = os.path.dirname(os.path.abspath(__file__)) |
| 12 |
resources = j(os.path.dirname(base), 'resources') |
| 13 |
icons = j(os.path.dirname(base), 'icons') |
| 14 |
srv = j(os.path.dirname(os.path.dirname(base)), 'srv') |
| 15 |
|
| 16 |
|
| 17 |
def render(outpath, sz, background=None): |
| 18 |
sz = str(sz) |
| 19 |
cmd = ['rsvg-convert', j(base, 'calibre.svg'), '-w', sz, '-h', sz, '-d', '96', '-p', '96', '-o', outpath] |
| 20 |
if background: |
| 21 |
cmd.insert(2, background), cmd.insert(2, '-b') |
| 22 |
subprocess.check_call(cmd) |
| 23 |
subprocess.check_call(['optipng', '-o7', '-strip', 'all', outpath]) |
| 24 |
|
| 25 |
|
| 26 |
render(j(resources, 'images', 'library.png'), 1024) |
| 27 |
render(j(resources, 'images', 'lt.png'), 256) |
| 28 |
render(j(resources, 'images', 'apple-touch-icon.png'), 256, 'white') |
| 29 |
render(j(resources, 'content-server', 'calibre.png'), 128) |
| 30 |
render(j(srv, 'main', 'calibre-paypal-logo.png'), 60) |
| 31 |
shutil.copy2(j(resources, 'content-server', 'calibre.png'), j(resources, 'content_server', 'calibre.png')) |
| 32 |
shutil.copy2(j(resources, 'images', 'lt.png'), j(srv, 'common', 'favicon.png')) |
| 33 |
shutil.copy2(j(resources, 'images', 'lt.png'), j(srv, 'common', 'favicon.png')) |
| 34 |
|
| 35 |
subprocess.check_call([sys.executable, j(icons, 'make_ico_files.py'), 'only-logo']) |
| 36 |
shutil.copy2(j(icons, 'library.ico'), j(srv, 'common', 'favicon.ico')) |
| 37 |
shutil.copy2(j(icons, 'library.ico'), j(srv, 'main/static/resources/img', 'favicon.ico')) |
| 38 |
shutil.copy2(j(icons, 'library.ico'), j(srv, 'open-books/drmfree/static/img', 'favicon.ico')) |
| 39 |
|
| 40 |
os.chdir(srv) |
| 41 |
subprocess.check_call(['git', 'commit', '-am', 'Update calibre favicons']) |
| 42 |
for s in 'main code open-books dl1'.split(): |
| 43 |
subprocess.check_call(['./publish', s, 'update']) |
| 44 |
|
| 45 |
subprocess.check_call([sys.executable, j(icons, 'icns', 'make_iconsets.py')]) |