I have an SVG file with 56 objects that I want to export as individual PNG files. I can do this with the subprocess module, but it involves executing Inkscape 56 times, and I'm looking for a better way. Inkscape has a command line interface with a shell mode, and I have been able to export items using the shell, but when I try to do this with the subprocess module, whatever command I issue is too long:
import subprocess as sp
proc =sp.Popen('inkscape -z --shell'.split(), stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE, universal_newlines=True)
x=proc.communicate('--help')
print(x)
("Inkscape 0.91 r13725 interactive shell mode. Type 'quit' to quit.\n>ERROR: Command line too long\n", '')
What am I doing wrong?
The inkscape error is misleading. The problem is a missing \n
.
proc.communicate('--help\n')