Skip to content

Commit

Permalink
add PNG support
Browse files Browse the repository at this point in the history
  • Loading branch information
artemtech committed Apr 12, 2020
1 parent 79b2d87 commit a98bc82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions inkporter.inx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<!-- one per page(tab) - unique names. Can discover which page in program-->
<page name="main" gui-text="Main">
<param name="format" type="enum" appearance="minimal" gui-text="Export Format">
<item value="png">PNG</item>
<item value="jpg">JPG</item>
<item value="pdf">PDF</item>
<item value="svg">SVG</item>
Expand Down
13 changes: 12 additions & 1 deletion inkporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ def __init__(self, *args, **kwargs):
self.tmpdir = tempfile.mkdtemp(prefix="inkporter")
self.tmplog_fd, self.tmplog_path = tempfile.mkstemp(prefix="inkporter", suffix=".log")
self.tmpout = []

def do_png(self):
for item in self.selected:
file_export = os.path.expandvars(
self.options.output_dir) + "/" + item + ".png"
command = "inkscape -z -j -i {0} -e '{1}' -d {2} -f '{3}' &>>{4}".format(
item, file_export, self.options.dpi, self.svg_file, self.tmplog_path)
os.system(command)
os.close(self.tmplog_fd)

def do_jpg(self):
if not self.has_imagemagick():
Expand Down Expand Up @@ -232,7 +241,9 @@ def effect(self):
try:
if not os.path.isdir(os.path.expandvars(self.options.output_dir)):
os.mkdir(os.path.expandvars(self.options.output_dir))
if self.options.format == "jpg":
if self.options.format == "png":
self.do_png()
elif self.options.format == "jpg":
self.do_jpg()
elif self.options.format == "pdf":
self.do_pdf()
Expand Down

0 comments on commit a98bc82

Please sign in to comment.