forked from qt-creator/qt-creator
icons/export.py: Make exporting of additional scale factors easier
This changes export.py in a way that adding a scale factor becomes easy. Change-Id: Ib6649be931d36bf21df429fe5dd237b440913743 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -77,9 +77,12 @@ for id in svgIDs:
|
|||||||
# The shell mode of Inkscape is used to execute several export commands
|
# The shell mode of Inkscape is used to execute several export commands
|
||||||
# with one launch of Inkscape.
|
# with one launch of Inkscape.
|
||||||
inkscapeShellCommands = ""
|
inkscapeShellCommands = ""
|
||||||
|
pngFiles = []
|
||||||
for id in svgIDs:
|
for id in svgIDs:
|
||||||
inkscapeShellCommands += "qtcreatoricons.svg --export-id=" + id + " --export-id-only --export-png=" + qtcSourceRoot + id + ".png --export-dpi=96\n"
|
for scale in [1, 2]:
|
||||||
inkscapeShellCommands += "qtcreatoricons.svg --export-id=" + id + " --export-id-only --export-png=" + qtcSourceRoot + id + "@2x.png --export-dpi=192\n"
|
pngFile = qtcSourceRoot + id + ("" if scale is 1 else "@%dx" % scale) + ".png"
|
||||||
|
pngFiles.append(pngFile)
|
||||||
|
inkscapeShellCommands += "qtcreatoricons.svg --export-id=" + id + " --export-id-only --export-png=" + pngFile + " --export-dpi=%d\n" % (scale * 96)
|
||||||
inkscapeShellCommands += "quit\n"
|
inkscapeShellCommands += "quit\n"
|
||||||
inkscapeProcess = subprocess.Popen(['inkscape', '--shell'], stdin=subprocess.PIPE, shell=True, cwd=scriptDir)
|
inkscapeProcess = subprocess.Popen(['inkscape', '--shell'], stdin=subprocess.PIPE, shell=True, cwd=scriptDir)
|
||||||
inkscapeProcess.communicate(input=inkscapeShellCommands.encode())
|
inkscapeProcess.communicate(input=inkscapeShellCommands.encode())
|
||||||
@@ -89,6 +92,5 @@ optipngExecutable = spawn.find_executable("optipng")
|
|||||||
if not optipngExecutable:
|
if not optipngExecutable:
|
||||||
sys.stderr.write("optipng was not found in PATH. Please do not push the unoptimized .pngs to the main repository.\n")
|
sys.stderr.write("optipng was not found in PATH. Please do not push the unoptimized .pngs to the main repository.\n")
|
||||||
else:
|
else:
|
||||||
for id in svgIDs:
|
for pngFile in pngFiles:
|
||||||
subprocess.call(["optipng", "-o7", "-strip", "all", qtcSourceRoot + id + ".png"])
|
subprocess.call(["optipng", "-o7", "-strip", "all", pngFile])
|
||||||
subprocess.call(["optipng", "-o7", "-strip", "all", qtcSourceRoot + id + "@2x.png"])
|
|
||||||
|
Reference in New Issue
Block a user