build: add a inkscape wrapper for 1.0 compatibility (#42481)
This commit is contained in:
parent
778996ee65
commit
d1843906f3
3
Makefile
3
Makefile
|
@ -1,5 +1,6 @@
|
|||
VERSION=`git describe | sed 's/^v//; s/-/./g' `
|
||||
NAME="publik-base-theme"
|
||||
INKSCAPE=$(shell pwd)/src/inkscape_wrapper.py
|
||||
|
||||
prefix = /usr
|
||||
|
||||
|
@ -46,7 +47,7 @@ icons:
|
|||
cd src/ && python3 render-imgs-categories.py ../static/hautes-alpes-2018/img/icon-rouge --primary B73720 --secondary B73720
|
||||
cd src/ && python3 render-imgs-categories.py ../static/hautes-alpes-2018/img/icon-bleu --primary 1C515E --secondary 1C515E
|
||||
# tournai
|
||||
cd static/tournai/ && for F in assets/*.svg; do inkscape --without-gui --file $$F --export-area-drawing --export-area-snap --export-png img/$$(basename $$F .svg).png --export-width 40; done
|
||||
cd static/tournai/ && for F in assets/*.svg; do $(INKSCAPE) --without-gui --file $$F --export-area-drawing --export-area-snap --export-png img/$$(basename $$F .svg).png --export-width 40; done
|
||||
|
||||
clean:
|
||||
rm -rf sdist
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#! /usr/bin/env python3
|
||||
# inkscape wrapper to support command-line parameters for <1.0 and 1.0
|
||||
# versions.
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
inkscape_version = subprocess.check_output('inkscape --version', shell=True)
|
||||
args = sys.argv[1:]
|
||||
if b'Inkscape 0' not in inkscape_version:
|
||||
# --export-png replaced by --export-filename
|
||||
# --without-gui and --file removed
|
||||
args = [x.replace('--export-png', '--export-filename') for x in args if x not in ('--without-gui', '--file')]
|
||||
|
||||
sys.exit(subprocess.call(['inkscape'] + args))
|
|
@ -23,6 +23,8 @@ import re
|
|||
import xml.etree.ElementTree as ET
|
||||
import sys
|
||||
|
||||
inkscape = os.path.abspath(os.path.join(os.path.dirname(__file__), 'inkscape_wrapper.py'))
|
||||
|
||||
names = {
|
||||
'02': 'famille',
|
||||
'03': 'papiers',
|
||||
|
@ -85,7 +87,6 @@ blacklist = [
|
|||
'M81.853,95.268c0,', # "
|
||||
]
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('path', help='out path')
|
||||
parser.add_argument('--primary', default='E0037A')
|
||||
|
@ -105,7 +106,7 @@ for filename in filenames:
|
|||
'E0037A', args.primary).replace(
|
||||
'6D1F80', args.secondary))
|
||||
fd.close()
|
||||
subprocess.call(['inkscape', '--without-gui',
|
||||
subprocess.call([inkscape, '--without-gui',
|
||||
'--file', 'tmp-%s.svg' % outname,
|
||||
'--export-area-page',
|
||||
'--export-png', os.path.join(path_out, '%s.png' % outname),
|
||||
|
@ -179,7 +180,7 @@ for filename in filenames:
|
|||
node.attrib['fill'] = 'none'
|
||||
node.attrib['stroke'] = '#FFFFFF'
|
||||
tree.write('tmp-%s.svg' % outname)
|
||||
subprocess.call(['inkscape', '--without-gui',
|
||||
subprocess.call([inkscape, '--without-gui',
|
||||
'--file', 'tmp-%s.svg' % outname,
|
||||
'--export-area-page',
|
||||
'--export-png', os.path.join(path_out, '%s-on.png' % outname),
|
||||
|
|
|
@ -24,6 +24,8 @@ import xml.etree.ElementTree as ET
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
inkscape = os.path.abspath(os.path.join(os.path.dirname(__file__), 'inkscape_wrapper.py'))
|
||||
|
||||
names = {
|
||||
'12': 'profile',
|
||||
'13': 'documents',
|
||||
|
@ -98,7 +100,7 @@ for filename in filenames:
|
|||
with tempfile.NamedTemporaryFile(suffix='.svg') as tmpfile:
|
||||
tree.write(tmpfile.name)
|
||||
tmpfile.flush()
|
||||
cmd = ['inkscape', '--without-gui',
|
||||
cmd = [inkscape, '--without-gui',
|
||||
'--file', tmpfile.name,
|
||||
'--export-area-drawing',
|
||||
'--export-png', out_filepath]
|
||||
|
|
Loading…
Reference in New Issue