bugGNU Octave - Bugs: bug #45285, printing with "-S..."...

 
 

bug #45285: printing with "-S..." option messes figure size and png output

Submitter:  Juan Pablo Carbajal <juanpi>
Submitted:  Tue 09 Jun 2015 05:50:07 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  juanpi Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 06 Feb 2018 07:41:30 AM UTC, comment #22: 

@Dmitri: this way you experienced the buggy and fixed behavior.

Closing report as fixed

Pantxo Diribarne <pantxo>
Group Member
Tue 06 Feb 2018 05:00:38 AM UTC, comment #21: 

I am sorry -- I was running the (old) installed version of octave rather than the compiled one (see octave vs ./run-octave).

It works fine once I corrected that.

Dmitri.
--
 

Dmitri A. Sergatskov <dasergatskov>
Tue 06 Feb 2018 12:05:24 AM UTC, comment #20: 

Things are working for me now after


changeset:   24688:dd68506c0926
bookmark:    @
tag:         tip
user:        Pantxo Diribarne <pantxo.diribarne@gmail.com>
date:        Mon Feb 05 22:14:34 2018 +0100
summary:     Fix print "-S" option parsing (bug #45285)



Rik <rik5>
Group administrator
Mon 05 Feb 2018 10:59:18 PM UTC, comment #19: 

Also, the interactive plot windows is just maximized into (one of) my
screens. Perhaps it is WM doing...

Dmitri.


Dmitri A. Sergatskov <dasergatskov>
Mon 05 Feb 2018 10:54:14 PM UTC, comment #18: 

I also have the same behavior as Dmitri.

Rik <rik5>
Group administrator
Mon 05 Feb 2018 10:43:23 PM UTC, comment #17: 


...
        idx = rindex (arg, ":");
        if (idx)
          arg_st.font = arg(3:idx-1);
          arg_st.fontsize = str2double (arg(idx+1:end));
        else
          arg_st.font = arg(3:end);
        endif
      elseif (length (arg) > 2 && arg(1:2) == "-S")
        arg_st.canvas_size = str2double (strsplit (arg(3:end), ","));
      elseif (length (arg) > 2 && arg(1:2) == "-r")
        arg_st.ghostscript.resolution = str2double (arg(3:end));
      elseif (length (arg) > 2 && arg(1:2) == "-f")
        arg_st.figure = str2double (arg(3:end));
      elseif (any (strcmp (arg, {"-painters", "-opengl"})))
        warning ("print: '%s' accepted for Matlab compatibility, but is ignored", arg);
      elseif (strcmp (arg, "-noui"))
        warning ("print: option '-noui' not yet implemented");
                                                                           152,9         23%
...


Dmitri A. Sergatskov <dasergatskov>
Mon 05 Feb 2018 10:37:10 PM UTC, comment #16: 

hg head
changeset:   24688:dd68506c0926
bookmark:    @
tag:         tip
user:        Pantxo Diribarne <pantxo.diribarne@gmail.com>
date:        Mon Feb 05 22:14:34 2018 +0100
summary:     Fix print "-S" option parsing (bug #45285)

hg id
dd68506c0926 tip @

I just did clean re-clone just in case...

Dmitri.

Dmitri A. Sergatskov <dasergatskov>
Mon 05 Feb 2018 10:35:02 PM UTC, comment #15: 

It works up to -S99,99
Beginning with -S100,100 -- it is an empty file.

Dmitri.


Dmitri A. Sergatskov <dasergatskov>
Mon 05 Feb 2018 10:33:58 PM UTC, comment #14: 

@Dmitri: I got the very same warnings (and huge png files that made my image viewer crash) before this cset:

http://hg.savannah.gnu.org/hgweb/octave/rev/dd68506c0926

Can you double check you have updated your build tree (and _print_parse_opts_ is fixed)?

Pantxo Diribarne <pantxo>
Group Member
Mon 05 Feb 2018 10:11:19 PM UTC, comment #13: 

+vervatim+
LIBGL_ALWAYS_SOFTWARE=1 LD_PRELOAD=/usr/lib64/libGLX_mesa.so.0 octave -f -q --no-gui
octave:1> close all
octave:2> graphics_toolkit qt
octave:3> figure(1);
octave:4> for i=1:3;

>   plot (randn (100,1));
>   print ('-dpng','-S3800,3800',sprintf ('eraseme%d.png',i));
> end

warning: gl2ps_renderer::draw_axes: empty feedback buffer and/or nothing else to print
warning: called from
    _opengl_print_ at line 155 column 7
    print at line 552 column 14
warning: gl2ps_renderer::draw_axes: empty feedback buffer and/or nothing else to print
warning: called from
    _opengl_print_ at line 155 column 7
    print at line 552 column 14
warning: gl2ps_renderer::draw_axes: empty feedback buffer and/or nothing else to print
warning: called from
    _opengl_print_ at line 155 column 7
    print at line 552 column 14
-verbatim-

and I get three large and apparently completely empty png files.

May be I am doing something wrong...

If I save it to svg, it is more obviously empty (attached).

dd68506c0926 tip @

Dmitri.


(file #43184)

Dmitri A. Sergatskov <dasergatskov>
Mon 05 Feb 2018 09:32:29 PM UTC, comment #12: 

After fixing the "-S" option parsing (there was a regression) [1], and preventing the figure window from being resized [2] I am now unable to reproduce the bug with the original scrip, and output size much larger than my screen:


close all
graphics_toolkit qt
figure(1);
for i=1:3;
  plot (randn (100,1));
  print ('-dpng','-S3800,3800',sprintf ('eraseme%d.png',i));
end


Can someone confirm so that I can close this report?

[1] http://hg.savannah.gnu.org/hgweb/octave/rev/dd68506c0926
[2] http://hg.savannah.gnu.org/hgweb/octave/rev/8b935067a257

Pantxo Diribarne <pantxo>
Group Member
Thu 09 Nov 2017 10:40:26 PM UTC, comment #11: 

Actually I spoke too soon, the workaround I provided is not equivalent to the "-S" option so it can't be used as a replacement for the current implementation.
The "-S" options changes the size of the figure while the workaround mainly changes the aspect ratio and the resolution (for raster formats only).

Pantxo Diribarne <pantxo>
Group Member
Thu 09 Nov 2017 06:04:19 AM UTC, comment #10: 

We don't need to support this option for Matlab compatibility, but would it be nice to keep it for quickly specifying the output size?  I understand that the equivalent scaling can be had by changing the paperposition property, but why can't Octave just do that for the user by specifying this single argument to print?

Rik <rik5>
Group administrator
Wed 08 Nov 2017 04:49:09 PM UTC, comment #9: 

@juanpi: I'd like to deprecate the "-S" option:

  • It is easy to do the same job with the "paperposition" property  and this technique avoids having to scale figures at very large size.


plot (1:10);
ppos = pos = get (gcf, "paperposition"); ## in inch
## Suppose we want a square figure with 4000 pixels sides
pos(4) = pos(3);
set (gcf, "paperposition", pos)
dpi = 4000/pos(3);
print (sprintf ("-r%d", dpi), "toto.png")

  • Matlab does not have it so there is no compatibility problem


Do you have any objection.

Pantxo Diribarne <pantxo>
Group Member
Thu 29 Dec 2016 09:22:32 PM UTC, comment #8: 

This issue is still present in Octave 4.2.0.

Running the sample code from comment #0 still produces one uncropped and two cropped png images on my Ubuntu PC.

Hartmut <hardy>
Wed 10 Jun 2015 10:09:12 PM UTC, comment #7: 

Thanks Juan Pablo, with these additional informations I can trigger the bug using very large figure size, e.g.


print ('-dpng','-S3800,3600',sprintf ('eraseme%d.png',i));


Not only even the first figures file is incorrect, but the figure window itself ends maximized.

Retitling again.

Pantxo Diribarne <pantxo>
Group Member
Wed 10 Jun 2015 07:05:22 PM UTC, comment #6: 

Hi,

I tried all possible combinations of pause and drawnow and the error appears all the time.

Indeed fltk and gnuplot do not show the issue.

The for loop is not needed. The script is not even needed. Once a plot is printed with a different resolution the followings are not correct. Calling clf doesn't solve the problem, one needs to close the figure and create a new one.

Printing to sizes smaller than the screen size doesn't trigger the problem.

Juan Pablo Carbajal <juanpi>
Group Member
Wed 10 Jun 2015 01:06:01 PM UTC, comment #5: 

@Juan Pi: the fact that it works offscreen (and I guess it also works with fltk) tells us that it is probably a threading issue like most of the problems we currently have with printing.

  • Can you try to move the pause before/after plot, and do the same with a "drawnow ()"?



  • Can you test if the for loop is needed, e.g run the following from a script (copy/paste in the command window may not trigger the bug):



close all
graphics_toolkit qt
figure(1);

plot (randn (100,1));
print ('-dpng','-S800,600','eraseme1.png');

plot (randn (100,1));
print ('-dpng','-S800,600','eraseme2.png');


plot (randn (100,1));
print ('-dpng','-S800,600','eraseme3.png');


  • The bug is probably triggered by the fact that you change the dpi. Can you check using the default resolution (without -S... option).


Pantxo Diribarne <pantxo>
Group Member
Wed 10 Jun 2015 11:13:56 AM UTC, comment #4: 

Let me add that I am running Ubuntu 15.04 with nvidia driver 340.76

Juan Pablo Carbajal <juanpi>
Group Member
Wed 10 Jun 2015 11:09:25 AM UTC, comment #3: 

Hi,

The extra pause doesn't solve the issue.

I am sorry to have misunderstood "off-screen", I thought it meant "to disk" or "to file". Anyways, if I run the modified code

close all
graphics_toolkit qt
figure(1);
set (gcf, "visible", "off")
for i=1:3;
  plot (randn (100,1));
  print ('-dpng','-S800,600',sprintf ('eraseme%d.png',i));
end


I get the right plots. If the image is visible I do not get the rigght plot, even if I add a pause. It seems that the screen doesn't resize after the s800,600 command.

Juan Pablo Carbajal <juanpi>
Group Member
Wed 10 Jun 2015 11:04:32 AM UTC, comment #2: 

I also couldn't reproduce this behavior using MXE-Octave on Win7.

Avinoam Kalma <avinoam>
Group Member
Wed 10 Jun 2015 10:24:29 AM UTC, comment #1: 

Hi,

I can't reproduce this behavior using a self compiled Octave 4.0 on linux mint 17.1: all 3 png are identical and conform to what I expect. There may be a timing issue that is raised depending on the graphics capabilities of your hardware.

Can you add add a "pause (1)" after the "print" statement and report back?

BTW why did you mention "off screen" plots in the title? We have been using this terminology when printing invisible figures ("visible" = "off").

Pantxo Diribarne <pantxo>
Group Member
Tue 09 Jun 2015 05:50:07 PM UTC, original submission:  


The following code

close all
graphics_toolkit qt
figure(1);
for i=1:3;
  plot (randn (100,1));
  print ('-dpng','-S800,600',sprintf ('eraseme%d.png',i));
end


Produces a first png figure that is correct but all sequential figures are trimmed. See attached figures

Juan Pablo Carbajal <juanpi>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #43184:  eraseme1.svg added by dasergatskov (672B - image/svg+xml)
file #34188:  qt_offscreen_fail.zip added by juanpi (53KiB - application/zip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Updated the item)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by juanpi (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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-02-06 pantxo StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-02-06 rik5 StatusConfirmed Ready For Test
    2018-02-05 dasergatskov Attached File- Added eraseme1.svg, #43184
    2016-12-30 rik5 Release4.0.0 dev
    2015-06-26 rik5 StatusWorks For Me Confirmed
    2015-06-10 pantxo CategoryPlotting Plotting with OpenGL
        SummaryPrinting qt figures from a for loop produces faulty files printing with "-S..." option messes figure size and png output
    2015-06-10 pantxo Summarygraphics_toolkit qt wrong off screen plot Printing qt figures from a for loop produces faulty files
    2015-06-10 pantxo StatusNone Works For Me
    2015-06-09 juanpi Attached File- Added qt_offscreen_fail.zip, #34188

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code