Allow import/export via stdin/stdout

Bug #171016 reported by Bug Importer
60
This bug affects 11 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Unassigned

Bug Description

I would love to be able to use Inkscape to convert SVG
to PNG, but I can't do it without using files as
intermediates. Please allow Inkscape to read SVG from
stdin and write output to stdout. This can easily be
done by checking for the special file names for '-'.

Thanks,
Jeremy

Revision history for this message
Bug Importer (bug-importer) wrote :

I strongly support this feature request. Actually, I wanted
to submit exactly the same request myself, but found this
one.

Thanks,
Vladimir

Revision history for this message
Bug Importer (bug-importer) wrote :

i want to request the same feature for inkview.

it would be *very* nice to use it together with any svg
generating application that outputs/can output svg(z) to
stdout... like dot (from graphviz)

Thanks,
Timo (<email address hidden>)

Revision history for this message
Rob263 (rob263) wrote :

Originator: NO

I would consider helping to code this enhancement, but I've never worked
on the Inkscape code before, so I'd need someone to point me in the right
direction in terms of which files/classed to start with.

nightrow (jb-benoit)
Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Niko Kiirala (kiirala) wrote :

To some extent, this can already be done by using special files /dev/stdin, /dev/stdout and /dev/stderr. Inkscape does emit a warning that it cannot determine the type of such a file, and tries to open it as SVG file.

On Windows those files obviously don't exist, but with mighty luck, same could be done using special filename con. I wouldn't hold my breath, though.

Revision history for this message
Tom Davidson (tjd-mit) wrote :

As was noted by tweenk in bug 174717 (marked as a dupe of this one) the /dev/stdin trick doesn't work for inkview. This is especially odd since inkview can autodetect svg files with missing file extensions.

Changed in inkscape:
status: Confirmed → Triaged
Revision history for this message
Marco Patzer (mpfusion) wrote :

Working with /dev/stdin and /dev/stdout doesn't really work:

$ inkscape -l /dev/stdout file.svg | head -2
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
terminate called after throwing an instance of 'Inkscape::IO::StreamException'
  what(): ERROR writing to file

Emergency save activated!
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at www.inkscape.org
with a detailed description of the steps leading to the crash, so we can fix it.
** Message: Error: Inkscape encountered an internal error and will close now.

However this works:

$ inkscape -l /dev/stdout file.svg | cat | head -2
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

It would be really nice to have proper stdin - stdout behaviour like most other programs.

su_v (suv-lp)
tags: added: cli importing
removed: import-export
Revision history for this message
Vassilis Virvilis (vasvir) wrote :

Hi,

+1 for this

If I use the /dev/stdout trick it doesn't really work because inkscape writes other stuff in the stdout and corrupts the png exported image.

I have to use | tail -n +3

Generally it is a pain to work with it in filters

For example

inkscape -z -b white -e a2.png a2.svg
parsing error: 1:618:could not recognize next production --> this is stderr
Background RRGGBBAA: ffffffff --> the rest is stdout
Area 0:0:1536:816 exported to 1536 x 816 pixels (96 dpi)
Bitmap saved as: a2.png

Thanks in advance

Revision history for this message
BrenBarn (brenbarn-c) wrote :

How nice to see this bug has been open for over 12 years with no progress. What a joke.

Revision history for this message
anatoly techtonik (techtonik) wrote :

Because it needs a patch.

I created separate issue for `inkview` - https://bugs.launchpad.net/inkscape/+bug/1804432

I could send a patch if `inkview` was written in Python (or Go WFIW), but it is not.

Revision history for this message
Patrick Storz (ede123) wrote :
Changed in inkscape:
milestone: none → 0.92.4
status: Triaged → Fix Committed
Revision history for this message
Vassilis Virvilis (vasvir) wrote :

Glad to hear that.

One problem closely related to this is that inkscape mixes stdout with stderr

I work around this with that.

inkscape -z -b white /dev/stdout /dev/stdin 2>/dev/null |
   sed -e '/^DPI:.*$/d' -e '/Background RRGGBBAA:.*$/d'
       -e '/Area 0:0:.*)$/d' -e 's/Bitmap saved as:.*stdout//g' |
   sed -z -e '$s/\\x0a$//g

Hopefully the commits you mentioned also take case of this.

Revision history for this message
Patrick Storz (ede123) wrote :

> One problem closely related to this is that inkscape mixes
> stdout with stderr

That particular issue was addressed in the commits mentioned.

However in the master branch there was yet another rewrite of the code in question, so some additional testing would be welcome.

Revision history for this message
Vassilis Virvilis (vasvir) wrote :

No problem to test preferably when 0.92.4 hits debian unstable.

Alternatively I could test it on flatpack or snap but that packages are the same or behind debian unstable.

Building from source is more involved but if you think that is required I could give it a try.

Thanks for all your efforts towards a very nice, useful and very well behaving software.

Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
Revision history for this message
Vassilis Virvilis (vasvir) wrote :

Hi this bug has resurfaced with 1.0.1 in Debian unstable.

This command
inkscape --export-type=png -p < a.svg > a.png

produces
  -lots of stuff in stderr: Cool
  -lots of lines before the PNG header: Not cool

The lines are of the form:
WARNING: Requested update while update in progress, counter = 5 (repeated 3064 times)
96dpi (repeated 84 times)

I think this printouts shouldn't go to stdout. That breaks the output files on stdout

I can provide the a.svg if required.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.