misc: write down license and author in the png files
|
@ -4,6 +4,9 @@ from optparse import OptionParser
|
|||
import subprocess
|
||||
import tempfile
|
||||
import xml.etree.ElementTree as ET
|
||||
import re
|
||||
from PIL import Image
|
||||
from PIL import PngImagePlugin
|
||||
|
||||
mapping = {
|
||||
'207': 'trash',
|
||||
|
@ -53,3 +56,20 @@ for icon_id, icon_name in mapping.items():
|
|||
'--file', svg_path,
|
||||
'--export-png', output_filename,
|
||||
'--export-width', '42'])
|
||||
|
||||
# write down licensing info in the png file
|
||||
meta = PngImagePlugin.PngInfo()
|
||||
license_txt = open('src/icon_%s/license.txt' % icon_id).read()
|
||||
try:
|
||||
meta.add_text('Author', re.findall('by(.*)', license_txt)[0], 0)
|
||||
except IndexError:
|
||||
pass
|
||||
license_txt = license_txt.replace('\n', ' ')
|
||||
for license in ['Public Domain', 'Creative Commons Attribution']:
|
||||
if license in license_txt:
|
||||
meta.add_text('Licence', license, 0)
|
||||
break
|
||||
else:
|
||||
print >> sys.stderr, 'Warning: no license known for', svg_path
|
||||
png_file = Image.open(output_filename)
|
||||
png_file.save(output_filename, "PNG", pnginfo=meta)
|
||||
|
|
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 792 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1009 B |
Before Width: | Height: | Size: 889 B After Width: | Height: | Size: 808 B |
Before Width: | Height: | Size: 980 B After Width: | Height: | Size: 917 B |
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 890 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 863 B After Width: | Height: | Size: 812 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 739 B After Width: | Height: | Size: 693 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 913 B |
Before Width: | Height: | Size: 1023 B After Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 712 B |
Before Width: | Height: | Size: 813 B After Width: | Height: | Size: 699 B |
Before Width: | Height: | Size: 771 B After Width: | Height: | Size: 635 B |
Before Width: | Height: | Size: 1004 B After Width: | Height: | Size: 966 B |
Before Width: | Height: | Size: 939 B After Width: | Height: | Size: 905 B |
Before Width: | Height: | Size: 948 B After Width: | Height: | Size: 938 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1017 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 667 B After Width: | Height: | Size: 629 B |