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,16 +2458,37 @@ class ChicagoPlus:
|
||||
|
||||
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))
|
||||
# this is a bit of a hack to support both version of inkscape
|
||||
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]
|
||||
|
||||
if int(inkscape_version) < 1:
|
||||
self.logger.debug("{:<21} | Using Inkscape v0.9x command".format(''))
|
||||
# Works with version 0.9x
|
||||
args = [
|
||||
inkscape_path,
|
||||
"-l", svg_out, svg_in
|
||||
]
|
||||
subprocess.check_call(args, stdout=subprocess.DEVNULL)
|
||||
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):
|
||||
self.logger.debug("{:<21} | Combining {} in {}".format("",color, tmpfile))
|
||||
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]
|
||||
|
||||
if int(inkscape_version) < 1:
|
||||
args = [
|
||||
inkscape_path,
|
||||
"--select="+color,
|
||||
@ -2478,12 +2499,28 @@ class ChicagoPlus:
|
||||
"--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)
|
||||
|
||||
|
||||
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))
|
||||
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)
|
||||
|
||||
if int(inkscape_version) < 1:
|
||||
args = [
|
||||
inkscape_path,
|
||||
"--without-gui",
|
||||
@ -2493,7 +2530,19 @@ class ChicagoPlus:
|
||||
"-h", size,
|
||||
"--export-png=" + png_out
|
||||
]
|
||||
subprocess.check_call(args, stdout=subprocess.DEVNULL)
|
||||
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):
|
||||
self.logger.debug("{:<21} | Converting {} to {}".format("", icon_filename, output_file_name))
|
||||
|
Loading…
x
Reference in New Issue
Block a user