bugGNU Octave - Bugs: bug #64473, Allow saveas() to directly write...

 
 

bug #64473: Allow saveas() to directly write to stdout

Submitter:  Janez Žemva <janezz55>
Submitted:  Wed 26 Jul 2023 07:56:17 AM UTC
   
 
Category:  Plotting Severity:  1 - Wish
Priority:  1 - Later Item Group:  Feature Request
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 8.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 08 Sep 2023 07:42:19 AM UTC, comment #4: 

supplying "/dev/stdout" won't work under Windows, I suppose, so I guess the bug should stay open. I am not sure if "/dev/stdout" is widely supported outside of linux either.

Janez Žemva <janezz55>
Thu 07 Sep 2023 06:47:37 PM UTC, comment #3: 

It is now possible to print to files with no extension (see bug #64510). The following now works:


plot (1:10)
print ("/dev/stdout", "-dsvg", "-nosvgconvert", "-no-append-file-extension")


Note that "-nosvgconvert" is necessary, otherwise octave-svgconvert will try to write a temporary file and replace /dev/strout with its own file (which is not permitted).

Can I close this report as fixed (even though one has to use the lower level `print` function rather than `saveas`)?

Pantxo Diribarne <pantxo>
Group Member
Thu 03 Aug 2023 09:17:04 AM UTC, comment #2: 

I believe there is some confusion on your side as regards this bug report. "/dev/stdout" and "/dev/stderr" are files, yet octave offers no way to save a plot to these files, indeed to any file that does not have an extension, which is a shortcoming. The problem with the workaround is that it may degrade some drives (SD/SSD), should not be necessary and is bad for performance reasons aswell.

Janez Žemva <janezz55>
Thu 03 Aug 2023 12:50:28 AM UTC, comment #1: 

The function saveas() is intended for files.  I don't believe Matlab allows "saving" files to stdout so there isn't any incentive to implement this feature from a compatibility perspective.  And in your Stack Overflow question you already demonstrate a workaround.  Hence, I don't think there will be much interest in implementing this feature.  For me, I would just use intermediate files.  Alternatively, you could patch your own local copy of Octave to accept the special filename '-'.  It's easy enough since it is just an m-file.

Rik <rik5>
Group administrator
Wed 26 Jul 2023 07:56:17 AM UTC, original submission:  

I need to stave figures in svg and png formats to stdout, unfortunately this does not work:

saveas(gcf, "/dev/stdout", "svg");

error: print: cannot open file /dev/stdout.svg for writing
error: called from
    print at line 447 column 7
    saveas at line 150 column 5

I have traced the issue to the file _print_parse_opts_.m, line 358:

  if (dot == 0 && ! isempty (arg_st.name) && ! isempty (default_suffix))
    arg_st.name = [arg_st.name "." default_suffix];
  endif

I propose either a new print option (e.g. -noextappend) is added, or a special filename (e.g. -) is designated as stdout (what to do with stderr?).

The issue on SO:
https://stackoverflow.com/questions/76746221/save-octave-figure-to-stdout

Janez Žemva <janezz55>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by janezz55 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-09-07 pantxo CategoryOctave Function Plotting
    2023-08-03 rik5 CategoryPlotting Octave Function
        Severity3 - Normal 1 - Wish
        Priority5 - Normal 1 - Later
        Item GroupUnexpected Error or Warning Feature Request
        StatusNone Confirmed
        Summaryoctave does not allow saving figures to stdout Allow saveas() to directly write to stdout

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code