Inkscape.org
Using Inkscape with Other Programs stdout empty when --export-emf is called within python 3.6.4
  1. #1
    aleksandarbos aleksandarbos @aleksandarbos
    *

    Hello everyone,

    At first, wanted to say thank you for this wonderful software and the whole hard work behind it!

    Since I'm trying to resolve the issue of inserting vector graphics to docx (MS Word) document, only supported formats are EMF and WMF, therefore I'm using inkscape for conversion. In order to avoid saving temporary files, tried using a new PIPE feature that's being available recently. 

    By executing the following code from Python, where `img_bytes` is BytesIO object wrapping SVG image, and bellow I'm executing the converson:

    res = subprocess.run(['inkscape', '--file', '-', '--export-emf', '-'], input=img_bytes.getvalue(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    print(res.stdout) # is empty byte array

    >> b''

    it also saves `EMF` file as `-` in the filesystem.

    Note if I change to `--export-png` everything works as expected, stdout is captured properly and no files were saved on the disk.

    Can anyone take a look and confirm the issue?

    Btw using Python 3.6.4 and Inkscape 0.92.4 (5da689c313, 2019-01-14).

    Best,

    Aleksandar

     

  2. #2
    Patrick Storz Patrick Storz @Ede_123

    Does it work when you run Inkscape directly from command line with these arguments?

    There's a chance the pipe feature is broken for EMF/WMF export, though, especially if it works for other formats, in which case you can report a bug at inkscape.org/report (note however that command line handling has changed significantly in upcoming Inkscape 1.0, so it might not be fixed anymore for the current stable 0.92.x release branch.

    In any case I'd like to encourage you to try this in a development build, though, as we're in desperate need of testers, especially for rarely used functionality like command line / piping.

Inkscape Inkscape.org Inkscape Forum Using Inkscape with Other Programs stdout empty when --export-emf is called within python 3.6.4