How to Use Inkscape's Command Line Options on Win32

On Windows you won't have much fun with Inkscape's command line options. They do work just fine, but you won't see any feedback messages. While the messages are written to stdout and stderr, these streams aren't connected to anything. And all that eventually useful information is flushed down the virtual toilet.

(If you aren't interested in the details skip over to InkCL.bat usage and the zip package.)

That's just how things are with Windows - either spawn a cmd.exe window or get nothing. Getting some extra cmd window each time you use Inkscape would be a tad annoying, therefore the other option was chosen. Java solves it with two executables: java.exe and javaw.exe (where the former spawns a cmd window and the latter doesn't).

In Java's case they are tiny wrappers. Inkscape is a lot bigger tho, therefore that wouldn't be the smartest thing to do. ~6.7mb just for better command line support? Naaah. However, a tiny separate wrapper program, which just spawns Inkscape.exe as child process would work fine. Ultimately it's the best option and most likely the one we'll pick.

As a temporary solution for the time being you can use the following Python program. It hands the command line arguments over to Inkscape and grabs the stdout and stderr streams and prints 'em on screen. (place it in the same directory as inkscape.exe)


import os, subprocess, sys

def spawn():
    run=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out,err=[e.splitlines() for e in run.communicate()]
    return run.returncode, out, err
if __name__=='__main__':
    if not r[0]==0:
        print 'return code:',r[0]
    for l in r[1]:
        print l
    for l in r[2]:
        print l usage:
python <inkscape options>

PNG export example:

C:\Inkscape-0.45.1-1\inkscape>python -e image.png ext.svg
Background RRGGBBAA: ffffff00
Area 0:0:64:64 exported to 64 x 64 pixels (90 dpi)
Bitmap saved as: image.png

If you don't have Python installed. Fear not! Inkscape is actually shipped with a Python interpreter, which is used by many extensions. We can use this interpreter and also shorten the command line by using a batch file.

InkCL.bat (place it in the same directory as inkscape.exe)

@"./python/python.exe" %*

InkCL.bat usage:
InkCL.bat <inkscape options>
The following also works:
inkcl <inkscape options>

PNG export example:

C:\Inkscape-0.45.1-1\inkscape>inkcl -e image.png ext.svg
Background RRGGBBAA: ffffff00
Area 0:0:64:64 exported to 64 x 64 pixels (90 dpi)
Bitmap saved as: image.png

Download: (1kb - contains:, InkCL.bat, and a readme)

Update: See inkscapec.exe - A Command Line Wrapper for Win32 for a better solution.


Talk About Timely!

Needed this tonight and bang! Just like that posted 5 days ago.

Thanks a lot! Saved me sooooo much time.

How to display Ink's Python stderr & stdout?

I'm new to Inkscape & Python and am trying to create a new path effect, but debugging the script seems impossible. I tried all three of your solutions, but can not find a way to redirect the Windows version of Inkscape's Python interpreter's stderr/out to a display or file. Both the script and message windows within Inkscape seem to be worthless and don't capture anything.

When I run my Python script within Inkscape, I get a Python error along with the script line number, but I can not seem to display any information from my script. For example, after getting an error I'll insert a line like "sys.stdout.write(v1)" to display the value of variable v1, but it's nowhere to be seen.

Do you have any suggestions?

blr3692 (at) onapplied (dot) com

re: How to display Ink's Python stderr & stdout?

It's a good idea to test the script externally first, which is possible if it either works on the complete document or if processing the whole thing is at least a possible path (many effects can either process everything or only the things in the selection).

Alternatively you can use Inkex's debug method.

import inkex
inkex.debug('hello world') looks like this:

def debug(what):
    sys.stderr.write(str(what) + "\n")
    return what

If you output something this way that "Inkscape has received additional data" dialog will pop up (the same you can see if an error occurs).

It's far from being ideal, but if you only need to check a few things it's alright-ish.

re: How to display Ink's Python stderr & stdout?

Excellent! It works! THANKS!!!

batch export of jpg files as svg files

HELP, I am new to programing for Inkscape, but need a batch file that I can run that will convert jpg files into plain svg files. I tried to figure this how to do this, but my programing skills are rusty.

Currently I am opening each jpg and then converting it to svg. With over 1000 files to do that to, I will be spending quite some time on this.

Thanks for any help you can give me.

Judy Perry
judylp[that a thing]littlebit[that dot thing]com

re: batch export of jpg files as svg files

Inkscape uses Potrace for that stuff. For batch conversion I recommend to use it directly. You can also give AutoTrace a try.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options