summaryrefslogtreecommitdiffstats
path: root/static/img/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'static/img/scripts')
-rw-r--r--static/img/scripts/credits.py21
-rwxr-xr-xstatic/img/scripts/generate-icons.sh25
-rw-r--r--static/img/scripts/generate.py47
3 files changed, 93 insertions, 0 deletions
diff --git a/static/img/scripts/credits.py b/static/img/scripts/credits.py
new file mode 100644
index 0000000..7e0a0ae
--- /dev/null
+++ b/static/img/scripts/credits.py
@@ -0,0 +1,21 @@
+#! /usr/bin/env python
+
+import xml.etree.ElementTree as ET
+import os
+
+print '<ul>'
+for filepath in sorted(os.listdir('sources')):
+ if not filepath.endswith('.svg'):
+ continue
+ tree = ET.fromstring(file('sources/' + filepath).read())
+ author = None
+ for elem in tree.getchildren():
+ if elem.tag == '{http://www.w3.org/2000/svg}text' and elem.text.startswith('Created by'):
+ author = elem.text[len('Created by')+1:]
+ tree.remove(elem)
+ break
+ else:
+ continue
+ print '<li>%s, par %s de <a href="http://thenounproject.com/">The Noun Project</a></li>' % (
+ filepath.split('.')[0].title(), author)
+print '</ul>'
diff --git a/static/img/scripts/generate-icons.sh b/static/img/scripts/generate-icons.sh
new file mode 100755
index 0000000..201118c
--- /dev/null
+++ b/static/img/scripts/generate-icons.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+
+python generate.py --width 160 --colour 888888 citoyens.svg metier.svg parametrage.svg
+python generate.py --width 160 --colour aaaaaa libre.svg data.svg
+
+python generate.py --width 80 --colour 888888 compte-citoyen.svg demarches.svg mobilite.svg porte-document.svg
+python generate.py --width 80 --colour 888888 administration.svg bi.svg federation-identite.svg webservices.svg
+python generate.py --width 80 --colour 888888 annonces.svg cms.svg fabrique-formulaires.svg guichet-unique.svg fabrique-workflows.svg
+
+
+python generate.py --width 160 --colour cccccc --variant bg compte-citoyen.svg
+python generate.py --width 160 --colour cccccc --variant bg mobilite.svg
+python generate.py --width 160 --colour cccccc --variant bg guichet-unique.svg
+python generate.py --width 160 --colour cccccc --variant bg fabrique-workflows.svg
+python generate.py --width 160 --colour cccccc --variant bg cms.svg
+python generate.py --width 160 --colour cccccc --variant bg administration.svg
+python generate.py --width 160 --colour cccccc --variant bg federation-identite.svg
+
+python generate.py --width 160 --colour 333333 --variant bg demarches.svg
+python generate.py --width 160 --colour 333333 --variant bg porte-document.svg
+python generate.py --width 160 --colour 333333 --variant bg fabrique-formulaires.svg
+python generate.py --width 160 --colour 333333 --variant bg annonces.svg
+python generate.py --width 160 --colour 333333 --variant bg webservices.svg
+python generate.py --width 160 --colour 333333 --variant bg bi.svg
+
diff --git a/static/img/scripts/generate.py b/static/img/scripts/generate.py
new file mode 100644
index 0000000..864cdfe
--- /dev/null
+++ b/static/img/scripts/generate.py
@@ -0,0 +1,47 @@
+#! /usr/bin/env python
+
+import os
+from optparse import OptionParser
+import subprocess
+import tempfile
+import xml.etree.ElementTree as ET
+import re
+from PIL import Image
+from PIL import PngImagePlugin
+import sys
+
+parser = OptionParser()
+parser.add_option('-c', '--colour', dest='colour', metavar='COLOUR')
+parser.add_option('-v', '--variant', dest='variant', metavar='VARIANT')
+parser.add_option('-w', '--width', dest='width', metavar='WIDTH', default='42')
+(options, args) = parser.parse_args()
+
+for svg_path in args:
+ output_filename = svg_path.replace('.svg', '.png')
+ svg_path = os.path.join('sources', svg_path)
+ if options.variant:
+ output_filename = output_filename.replace('.png', '-%s.png' % options.variant)
+ author = None
+ if options.colour:
+ tree = ET.fromstring(file(svg_path).read().replace('#000000', '#%s' % options.colour))
+ for elem in tree.findall('*'):
+ if not elem.attrib.get('style'):
+ elem.attrib['style'] = 'fill:#%s' % options.colour
+ for elem in tree.getchildren():
+ if elem.tag == '{http://www.w3.org/2000/svg}text' and elem.text.startswith('Created by'):
+ author = elem.text[len('Created by')+1:]
+ tree.remove(elem)
+ for elem in tree.getchildren():
+ if elem.tag == '{http://www.w3.org/2000/svg}text' and 'Noun Project' in elem.text:
+ tree.remove(elem)
+ f = tempfile.NamedTemporaryFile(suffix='.svg', delete=False)
+ f.write(ET.tostring(tree))
+ f.close()
+ svg_path = f.name
+ # XXX: add author to png metadata
+ subprocess.call(['inkscape', '--without-gui',
+ '--file', svg_path,
+ '--export-area-drawing',
+ '--export-area-snap',
+ '--export-png', output_filename,
+ '--export-width', options.width])