From bba2a2521b9692d3156f3126f95f62289d92d891 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Sat, 6 Oct 2018 00:07:58 +0200 Subject: [PATCH] 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 --- src/tools/icons/export.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tools/icons/export.py b/src/tools/icons/export.py index e28b7e6e4e9..6943b18fd74 100644 --- a/src/tools/icons/export.py +++ b/src/tools/icons/export.py @@ -77,9 +77,12 @@ for id in svgIDs: # The shell mode of Inkscape is used to execute several export commands # with one launch of Inkscape. inkscapeShellCommands = "" +pngFiles = [] for id in svgIDs: - inkscapeShellCommands += "qtcreatoricons.svg --export-id=" + id + " --export-id-only --export-png=" + qtcSourceRoot + id + ".png --export-dpi=96\n" - inkscapeShellCommands += "qtcreatoricons.svg --export-id=" + id + " --export-id-only --export-png=" + qtcSourceRoot + id + "@2x.png --export-dpi=192\n" + for scale in [1, 2]: + 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" inkscapeProcess = subprocess.Popen(['inkscape', '--shell'], stdin=subprocess.PIPE, shell=True, cwd=scriptDir) inkscapeProcess.communicate(input=inkscapeShellCommands.encode()) @@ -89,6 +92,5 @@ optipngExecutable = spawn.find_executable("optipng") if not optipngExecutable: sys.stderr.write("optipng was not found in PATH. Please do not push the unoptimized .pngs to the main repository.\n") else: - for id in svgIDs: - subprocess.call(["optipng", "-o7", "-strip", "all", qtcSourceRoot + id + ".png"]) - subprocess.call(["optipng", "-o7", "-strip", "all", qtcSourceRoot + id + "@2x.png"]) + for pngFile in pngFiles: + subprocess.call(["optipng", "-o7", "-strip", "all", pngFile])