mirror of
https://github.com/grassmunk/Chicago95.git
synced 2025-09-25 18:58:40 +02:00
Major changes to the commandline interface in Inkscape required a few functions to be rewritten/perform a check for which version is being used more infor here: https://wiki.inkscape.org/wiki/index.php/Release_notes/1.0#Command_Line. This resolves #135.
This commit is contained in:
parent
bfbc77f403
commit
7501f78931
@ -2458,42 +2458,91 @@ class ChicagoPlus:
|
|||||||
|
|
||||||
def convert_to_proper_svg_with_inkscape(self, svg_out, svg_in):
|
def convert_to_proper_svg_with_inkscape(self, svg_out, svg_in):
|
||||||
self.logger.debug("{:<21} | Converting {} to {} with Inkscape".format("",svg_out, svg_in))
|
self.logger.debug("{:<21} | Converting {} to {} with Inkscape".format("",svg_out, svg_in))
|
||||||
|
# this is a bit of a hack to support both version of inkscape
|
||||||
inkscape_path = subprocess.check_output(["which", "inkscape"]).strip()
|
inkscape_path = subprocess.check_output(["which", "inkscape"]).strip()
|
||||||
args = [
|
inkscape_version_cmd = subprocess.check_output([inkscape_path, "--version"])
|
||||||
inkscape_path,
|
inkscape_version = inkscape_version_cmd.splitlines()[0].split()[1].decode().split(".")[0]
|
||||||
"-l", svg_out, svg_in
|
|
||||||
]
|
if int(inkscape_version) < 1:
|
||||||
subprocess.check_call(args, stdout=subprocess.DEVNULL)
|
self.logger.debug("{:<21} | Using Inkscape v0.9x command".format(''))
|
||||||
|
# Works with version 0.9x
|
||||||
|
args = [
|
||||||
|
inkscape_path,
|
||||||
|
"-l", svg_out, svg_in
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
self.logger.debug("{:<21} | Using Inkscape v1.0 command".format(''))
|
||||||
|
#works with version 1.0
|
||||||
|
args = [
|
||||||
|
inkscape_path,
|
||||||
|
"-l", "-o", svg_out, svg_in
|
||||||
|
]
|
||||||
|
|
||||||
|
subprocess.check_call(args, stderr=subprocess.DEVNULL ,stdout=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
def fix_with_inkscape(self, color, tmpfile):
|
def fix_with_inkscape(self, color, tmpfile):
|
||||||
self.logger.debug("{:<21} | Combining {} in {}".format("",color, tmpfile))
|
self.logger.debug("{:<21} | Combining {} in {}".format("",color, tmpfile))
|
||||||
inkscape_path = subprocess.check_output(["which", "inkscape"]).strip()
|
inkscape_path = subprocess.check_output(["which", "inkscape"]).strip()
|
||||||
args = [
|
|
||||||
inkscape_path,
|
inkscape_version_cmd = subprocess.check_output([inkscape_path, "--version"])
|
||||||
"--select="+color,
|
inkscape_version = inkscape_version_cmd.splitlines()[0].split()[1].decode().split(".")[0]
|
||||||
"--verb", "EditSelectSameFillColor",
|
|
||||||
"--verb", "SelectionCombine",
|
if int(inkscape_version) < 1:
|
||||||
"--verb", "SelectionUnion",
|
args = [
|
||||||
"--verb", "FileSave",
|
inkscape_path,
|
||||||
"--verb", "FileQuit",
|
"--select="+color,
|
||||||
tmpfile
|
"--verb", "EditSelectSameFillColor",
|
||||||
]
|
"--verb", "SelectionCombine",
|
||||||
|
"--verb", "SelectionUnion",
|
||||||
|
"--verb", "FileSave",
|
||||||
|
"--verb", "FileQuit",
|
||||||
|
tmpfile
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
args = [
|
||||||
|
inkscape_path,
|
||||||
|
"-g",
|
||||||
|
"--select="+color,
|
||||||
|
"--verb", "EditSelectSameFillColor;SelectionCombine;SelectionUnion;FileSave;FileQuit",
|
||||||
|
tmpfile
|
||||||
|
]
|
||||||
|
|
||||||
subprocess.check_call(args, stderr=subprocess.DEVNULL ,stdout=subprocess.DEVNULL)
|
subprocess.check_call(args, stderr=subprocess.DEVNULL ,stdout=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
def convert_to_png_with_inkscape(self, svg_in, size, png_out):
|
def convert_to_png_with_inkscape(self, svg_in, size, png_out):
|
||||||
self.logger.debug("{:<21} | Converting {} to {} of size {}".format("", svg_in, png_out, size))
|
self.logger.debug("{:<21} | Converting {} to {} of size {}".format("", svg_in, png_out, size))
|
||||||
inkscape_path = subprocess.check_output(["which", "inkscape"]).strip()
|
inkscape_path = subprocess.check_output(["which", "inkscape"]).strip()
|
||||||
|
|
||||||
|
inkscape_version_cmd = subprocess.check_output([inkscape_path, "--version"])
|
||||||
|
inkscape_version = inkscape_version_cmd.splitlines()[0].split()[1].decode().split(".")[0]
|
||||||
|
|
||||||
size = str(size)
|
size = str(size)
|
||||||
args = [
|
|
||||||
inkscape_path,
|
if int(inkscape_version) < 1:
|
||||||
"--without-gui",
|
args = [
|
||||||
"-f", svg_in,
|
inkscape_path,
|
||||||
"--export-area-page",
|
"--without-gui",
|
||||||
"-w", size,
|
"-f", svg_in,
|
||||||
"-h", size,
|
"--export-area-page",
|
||||||
"--export-png=" + png_out
|
"-w", size,
|
||||||
]
|
"-h", size,
|
||||||
subprocess.check_call(args, stdout=subprocess.DEVNULL)
|
"--export-png=" + png_out
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
args = [
|
||||||
|
inkscape_path,
|
||||||
|
"--export-area-page",
|
||||||
|
"--export-type=png",
|
||||||
|
"-w", size,
|
||||||
|
"-h", size,
|
||||||
|
"-o", png_out,
|
||||||
|
svg_in
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
subprocess.check_call(args, stderr=subprocess.DEVNULL ,stdout=subprocess.DEVNULL)
|
||||||
|
|
||||||
def convert_ico_files(self, icon_filename, output_file_name):
|
def convert_ico_files(self, icon_filename, output_file_name):
|
||||||
self.logger.debug("{:<21} | Converting {} to {}".format("", icon_filename, output_file_name))
|
self.logger.debug("{:<21} | Converting {} to {}".format("", icon_filename, output_file_name))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user