bugGNU Octave - Bugs: bug #57143, print ('-tight', 'q.eps') produces...

 
 

bug #57143: print ('-tight', 'q.eps') produces no file

Submitter:  None
Submitted:  Wed 30 Oct 2019 03:10:16 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.0.90
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 11 Apr 2020 11:28:01 PM UTC, comment #20: 

I applied the modified patch to the stable branch here https://hg.savannah.gnu.org/hgweb/octave/rev/c3dd445fcc2f.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Sat 11 Apr 2020 06:20:10 AM UTC, comment #19: 

Rik, your patch works almost great.

Content of file #48807:


diff -r bc6dae9cbe73 scripts/plot/util/print.m
--- a/scripts/plot/util/print.m        Thu Apr 09 15:35:57 2020 -0700
+++ b/scripts/plot/util/print.m        Sat Apr 11 15:10:38 2020 +0900
@@ -890,8 +890,16 @@ function cmd = epstool (opts, filein, fi
       cmd = "";
     endif
     if (! isempty (cmd))
-      cmd = sprintf ("%s --quiet %s %s %s ", opts.epstool_binary,
-                     cmd, filein, fileout);
+      if (dos_shell)
+        ## ghostscript expects double, not single, quotes
+        fileout(fileout=="'") = '"';
+        ## epstool implicitly uses ghostscript and it needs the command name
+        cmd = sprintf ("%s --gs %s --quiet %s %s %s ", opts.epstool_binary,
+                       opts.ghostscript.binary, cmd, filein, fileout);
+      else
+        cmd = sprintf ("%s --quiet %s %s %s ", opts.epstool_binary,
+                       cmd, filein, fileout);
+      endif
     endif
     if (pipein)
       if (dos_shell)


I extended it by the lines


## ghostscript expects double, not single, quotes
fileout(fileout=="'") = '"';


as otherwise the output filename of comment #9 is surrounded by 'filename' single quotation marks.

Kai Torben Ohlhus <siko1056>
Group Member
Thu 09 Apr 2020 11:25:09 PM UTC, comment #18: 

I don't have access to a Windows system.  Could someone try the attached patch against the m-file print.m?  It implements the idea in comment #17 which is to pass the location of the ghostscript binary to epstool.

(file #48797)

Rik <rik5>
Group administrator
Thu 12 Mar 2020 03:43:12 PM UTC, comment #17: 

This is pretty stupid, but hopefully has an easy workaround.  If I do 'man epstool' on Linux I notice this option


 --gs command
              Specify the name the ghostscript program. On Unix the default is gs.  On Windows, epstool will  check  the
              registry for installed versions of ghostscript and use the latest, otherwise it will use gswin32c.exe.


So it would seem that on Windows platforms we could also pass this option and give it the correct name of the ghostscript executable.


Rik <rik5>
Group administrator
Thu 12 Mar 2020 06:20:15 AM UTC, comment #16: 

After writing I got the simple stupid idea how to prove my assumption:

copy & rename "gs.exe" such that both exist:

C:\Octave\Octave-6.0.1\mingw64\bin\gs.exe
C:\Octave\Octave-6.0.1\mingw64\bin\gswin32c.exe

And "print -tight" works perfectly fine =)

Thus how to fix this properly?

Kai Torben Ohlhus <siko1056>
Group Member
Thu 12 Mar 2020 06:12:26 AM UTC, comment #15: 

Maybe I came a step closer to the root cause.  In short: epstool cannot invoke ghostscript correctly due to a hardcoded bad assumption.

Details:

I tried the fix of Rik comment #13.  Indeed this can be changed, as it has no effect on the output of the first step calling ghostscript (gs.exe).  But it was not the solution.

Next I committed the cleanup "& del ..." and removed the "--quiet" option from the "epstool.exe" call.  This revealed two things:

1. The temporary file by the first step in the pipeline of gs.exe is created.
2. The further processing by epstool.exe is broken.

The same happens from Octave, but I invoked the command directly from the temp directory to show the details:


>> system ("epstool.exe --copy --bbox oct-GAt3ba.eps blub.eps")
"gswin32c.exe"  -dNOPAUSE -dBATCH -sDEVICE=bbox   -c "<</PageSize [9400 9400] /PageOffset [30
00 3000]>> setpagedevice" -f "c:\users\siko1056\appdata\local\temp\gsviewa06976"
Ghostscript failed to obtain bounding box
Failed
ans = 1


Especially, I was curious about "gswin32c.exe".  Octave's Ghostscript is called "gs.exe".


>> system ("where gs")
C:\Octave\Octave-6.0.1\mingw64\bin\gs.exe
ans = 0

>> system ("where gswin32c")
INFO: Could not find files for the given pattern(s).
ans = 1

>> system ("where gswin32c.exe")
INFO: Could not find files for the given pattern(s).
ans = 1

>> system ("gswin32c.exe")
'gswin32c.exe' is not recognized as an internal or external command,
operable program or batch file.


In epstool-3.08 this decision is hardcoded (src/epstool.c):


#ifdef _WIN32
TCHAR gsexe[MAXSTR] = TEXT("gswin32c.exe");
#define COLOUR_DEVICE TEXT("bmp16m")
#define GREY_DEVICE TEXT("bmpgray")
#define MONO_DEVICE TEXT("bmpmono")
#endif


Maybe MXE needs to patch this file?

Further note:  There is an epstool-3.09, but the tar.gz file seems to be broken.  I'll contact the maintainer to ask for advice.

Kai Torben Ohlhus <siko1056>
Group Member
Wed 11 Mar 2020 04:11:56 PM UTC, comment #14: 

OP here, no longer have access to the original win10 machine, but I thank rik5 for keeping at it.

Anonymous
Wed 11 Mar 2020 03:31:49 PM UTC, comment #13: 

This bit of code looks suspect


    if (pipein)
      if (dos_shell)
        filein(filein=="'") = '"';
        gs_cmd = __ghostscript__ ("binary", opts.ghostscript.binary,
                                  "device", epsdevice,
                                  "source", "-",
                                  "output", filein);
        cmd = sprintf ("%s %s & %s", gs_cmd, filein, cmd);
      else
        cmd = sprintf ("cat > %s ; %s", filein, cmd);
      endif
    endif


My guess is that when dos_shell is true, gs_cmd already includes filein, and therefore the code should not be


cmd = sprintf ("%s %s & %s", gs_cmd, filein, cmd);


but instead


cmd = sprintf ("%s & %s", gs_cmd, cmd);


I have no access to Windows so I can test this, but it would be simple enough to edit the file print.m in an existing Windows installation to test.

Rik <rik5>
Group administrator
Wed 11 Mar 2020 03:18:03 PM UTC, comment #12: 

I would start with reviewing the file scripts/plot/util/print.m and the subfunction epstool.


function cmd = epstool (opts, filein, fileout)
  ## As epstool does not work with pipes, a subshell is used to
  ## permit piping.  Since this solution does not work with the DOS
  ## command shell, the -tight and -preview options are disabled if
  ## output must be piped.

  ## DOS Shell:
  ##   gs.exe [...] -sOutputFile=<filein> - & epstool -bbox -preview-tiff <filein> <fileout> & del <filein>
  ## Unix Shell;
  ##   cat > <filein> ; epstool -bbox -preview-tiff <filein> <fileout> ; rm <filein>


I don't know if the comment is meaningful about -tight being disabled.  Also, command that is eventually used is contstructed by parts in this function.  I would examine it carefully because it is the source of the extra output filename being placed in the command.

Rik <rik5>
Group administrator
Wed 11 Mar 2020 02:44:38 PM UTC, comment #11: 

What about my question from comment #7?  It appears that the shell command in Windows may be incorrectly generated.  The end of the gs.exe command is signaled with '-', but then the temporary file name appears, and then '&' and the next command with epstool.exe.

Rik <rik5>
Group administrator
Wed 11 Mar 2020 02:35:34 PM UTC, comment #10: 

This works on Linux as remarked in comment #8.  Changing the "Operating System" to Microsoft Windows.

Rik <rik5>
Group administrator
Wed 11 Mar 2020 04:56:52 AM UTC, comment #9: 

Tested with an Octave 6 (stable) build from 2020-02-28 (there were not so many changes on stable since then).

https://hg.savannah.gnu.org/hgweb/octave/rev/4f1d1b1d4afc
https://hg.octave.org/mxe-octave/rev/25a483af6aa7


>> __octave_config_info__ ("hg_id")
ans = 4f1d1b1d4afc

>> plot(1:10)

>> plot(1:10)
>> print -tight -debug tight.eps
epstool command: 'C:\Octave\OCTAVE~1.1\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRota
tePages=/None -sDEVICE=eps2write -sOutputFile="C:\Users\siko1056\AppData\Local\Temp\oct-7uhRBz.eps" -
C:\Users\siko1056\AppData\Local\Temp\oct-7uhRBz.eps & C:\Octave\OCTAVE~1.1\mingw64\bin\epstool.exe --q
uiet --copy --bbox C:\Users\siko1056\AppData\Local\Temp\oct-7uhRBz.eps 'tight.eps'  & del "C:\Users\si
ko1056\AppData\Local\Temp\oct-7uhRBz.eps" '
opengl-pipeline: 'C:\Octave\OCTAVE~1.1\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRota
tePages=/None -sDEVICE=eps2write -sOutputFile="C:\Users\siko1056\AppData\Local\Temp\oct-7uhRBz.eps" -
C:\Users\siko1056\AppData\Local\Temp\oct-7uhRBz.eps & C:\Octave\OCTAVE~1.1\mingw64\bin\epstool.exe --q
uiet --copy --bbox C:\Users\siko1056\AppData\Local\Temp\oct-7uhRBz.eps 'tight.eps'  & del "C:\Users\si
ko1056\AppData\Local\Temp\oct-7uhRBz.eps" '

>> print -loose -debug loose.eps
epstool command: 'C:\Octave\OCTAVE~1.1\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRota
tePages=/None -sDEVICE=eps2write -sOutputFile=""loose.eps"" -'
opengl-pipeline: 'C:\Octave\OCTAVE~1.1\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRota
tePages=/None -sDEVICE=eps2write -sOutputFile=""loose.eps"" -'


Same like with Octave 5.2.0 only the last command produced an eps figure.

Kai Torben Ohlhus <siko1056>
Group Member
Thu 05 Mar 2020 10:23:47 PM UTC, comment #8: 

This bug seems to have stalled for the past few months. The original issue was resolved on GNU/Linux systems, the problem being a missing epstool executable.

Is there anything that needs to be tested or fixed on Windows? Can someone test a recent build from the version 6 stable branch on Windows to see if this is working or if a fix is needed?

Mike Miller <mtmiller>
Group Member
Fri 15 Nov 2019 11:19:24 PM UTC, comment #7: 

It looks to me like the pipeline might be incorrectly created on Windows.  On Linux there is a ';' to separate the commands given to the shell.  On Windows, the character is '&'.  However, it looks like the temporary filename used by gs.exe is being replicated.

The command from comment #6 is


opengl-pipeline: 'C:\Octave\OCTAVE~1.0\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=eps2write -sOutputFile="C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps" - C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps & C:\Octave\OCTAVE~1.0\mingw64\bin\epstool.exe --quiet --copy --bbox C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps 'tight.eps'  & del C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps '


I think this should be


opengl-pipeline: 'C:\Octave\OCTAVE~1.0\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=eps2write -sOutputFile="C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps" -


Followed by


& C:\Octave\OCTAVE~1.0\mingw64\bin\epstool.exe --quiet --copy --bbox C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps 'tight.eps'  & del C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps '


without


C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps


in the middle.

Rik <rik5>
Group administrator
Thu 31 Oct 2019 12:34:08 PM UTC, comment #6: 

I've noticed several epstool errors with latex, and something else I believe, however, there was no package in the repo, so I gave up using eps on my void machine.

Anyways; on w10 I get the following

octave:2> plot (1:10)
octave:3> print -tight -debug tight.eps
epstool command: 'C:\Octave\OCTAVE~1.0\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=eps2write -sOutputFile="C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps" - C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps & C:\Octave\OCTAVE~1.0\mingw64\bin\epstool.exe --quiet --copy --bbox C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps 'tight.eps'  & del C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps '
opengl-pipeline: 'C:\Octave\OCTAVE~1.0\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=eps2write -sOutputFile="C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps" - C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps & C:\Octave\OCTAVE~1.0\mingw64\bin\epstool.exe --quiet --copy --bbox C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps 'tight.eps'  & del C:\Users\vlg\AppData\Local\Temp\oct-3eMH9a.eps '
octave:4> print -loose -debug loose.eps
epstool command: 'C:\Octave\OCTAVE~1.0\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=eps2write -sOutputFile=""loose.eps"" -'
opengl-pipeline: 'C:\Octave\OCTAVE~1.0\mingw64\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=eps2write -sOutputFile=""loose.eps"" -'

Again, only  the loose one gets created.

Anonymous
Thu 31 Oct 2019 11:48:13 AM UTC, comment #5: 

You did not mention the error message you get when using "-tight", which is pretty clear to me: you either don't have "epstool" installed (in which case you need to install it, this is not a bug) or Octave is unable to find it. This is for linux.

Now on your Windows 10 machine, you probably won't get this error message since epstool is bundled with the Octave. Could you run this script again on Windows?

Pantxo Diribarne <pantxo>
Group Member
Thu 31 Oct 2019 10:44:20 AM UTC, comment #4: 

I get

octave:5> plot (1:10)
octave:6> print -tight -debug /tmp/tight.eps
error: print.m: 'epstool' is required for specified output format, but binary is not available in PATH
error: called from
    print>epstool at line 809 column 7
    __opengl_print__ at line 42 column 16
    print at line 710 column 16
octave:6> print -loose -debug /tmp/loose.eps
epstool command: ' cat > '/tmp/loose.eps' '
opengl-pipeline: ' cat > '/tmp/loose.eps' '


The loose one's is the bin, the tight one's not.I get

octave:5> plot (1:10)
octave:6> print -tight -debug /tmp/tight.eps
error: print.m: 'epstool' is required for specified output format, but binary is not available in PATH
error: called from
    print>epstool at line 809 column 7
    __opengl_print__ at line 42 column 16
    print at line 710 column 16
octave:6> print -loose -debug /tmp/loose.eps
epstool command: ' cat > '/tmp/loose.eps' '
opengl-pipeline: ' cat > '/tmp/loose.eps' '


The loose one's is the bin, the tight one's not.

This is from Void, I just have the octave pkg as provided by the glibc repo, if it matters any.

(file #47774)

Anonymous
Thu 31 Oct 2019 10:23:21 AM UTC, comment #3: 

Yes, "looseinset" is a hidden property. It is used by internal functions and you should normally not have to play with it, it is even discouraged, unless you know what you are doing.

Could you run the script below with the hidden option (again :-))  "-debug" so that we can eventually see what is going wrong:


plot (1:10)
print -tight -debug /tmp/tight.eps
print -loose -debug /tmp/loose.eps


For me this produces two files which I attached, and the following outputs on stdout:


>> plot (1:10)
>> print -tight -debug /tmp/tight.eps
epstool command: 'cat > /tmp/oct-EPwBgs.eps ; /usr/bin/epstool --quiet --copy --bbox /tmp/oct-EPwBgs.eps '/tmp/tight.eps'  ; rm /tmp/oct-EPwBgs.eps '
opengl-pipeline: 'cat > /tmp/oct-EPwBgs.eps ; /usr/bin/epstool --quiet --copy --bbox /tmp/oct-EPwBgs.eps '/tmp/tight.eps'  ; rm /tmp/oct-EPwBgs.eps '
>> print -loose -debug /tmp/loose.eps
epstool command: ' cat > '/tmp/loose.eps' '
opengl-pipeline: ' cat > '/tmp/loose.eps' '


I attached the resulting files, obtained on debian stretch with self compiled Octave 5.1.

(file #47772, file #47773)

Pantxo Diribarne <pantxo>
Group Member
Thu 31 Oct 2019 08:27:43 AM UTC, comment #2: 

comment #1:

> * What graphics toolkit are you using?

graphics_toolkit is qt on both OS, although I don't know how to change it, and of what use it'll be, haven't read that part of the documentation.

> * You marked this bug as affecting any OS. Did you try on several different OSs?

On Void Linux and Win10 there is no output file. Although, and I should've mentioned this earlier, it does process something, just that it doesn't result in an output file.

> In any event, you can tweak the figure to change the margins using the hidden axes property "looseinset", e.g.:
> set (gca, "looseinset", [0.02 0.02 0.02 0.02])


The documentation for 5.1.0 doesn't have anything about `looseinset`, only a

tightinset (read-only): four-element vector
    Size of the [left bottom right top] margins around the axes that enclose labels and title annotations.


However, the example given works handsomely with the 1:10; fiddling around with the numbers:
[0, 0, 0, 0] tightened the vertical margins, while [1, 1, 1, 1] fully excised them, also lessening the horizontal one, thought they're still big- together around a 1/3--1/2 of the actual figure width, actual plot area being a (almost always) square in size.

Anonymous
Wed 30 Oct 2019 03:30:50 PM UTC, comment #1: 

There are already a couple of know issues about the -tight option (at least bug #55723 and bug #56289). To determine if your problem is already reported, we'll need some more info:

  • What graphics toolkit are you using?
  • You marked this bug as affecting any OS. Did you try on several different OSs?


In any event, you can tweak the figure to change the margins using the hidden axes property "looseinset", e.g.:


plot (1:10)
set (gca, "looseinset", [0.02 0.02 0.02 0.02])
print toto.eps


Pantxo Diribarne <pantxo>
Group Member
Wed 30 Oct 2019 03:10:16 PM UTC, original submission:  

Trying to get the giant white margins removed still in Octave, rather than in latex via cropping, I found out that '-Sx,y' scales rather than crops, and that I always get the margins. .eps has a -tight/-loose option, the latter being default, with which a file is created, be it with the option implicit or explicit.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #48807:  bug57143_2.patch added by siko1056 (938B - text/x-patch)
file #48797:  bug57143.patch added by rik5 (841B - text/x-patch)
file #47774:  loose.eps added by None (7KiB - image/x-eps)
file #47772:  loose.eps added by pantxo (7KiB - image/x-eps)
file #47773:  tight.eps added by pantxo (7KiB - image/x-eps)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by None (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 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-04-11 rik5 StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
    2020-04-11 siko1056 StatusConfirmed Patch Reviewed
    2020-04-11 siko1056 Attached File- Added bug57143_2.patch, #48807
    2020-04-09 rik5 Attached File- Added bug57143.patch, #48797
    2020-03-12 rik5 StatusNeed Info Confirmed
    2020-03-11 rik5 Operating SystemAny Microsoft Windows
    2020-03-11 siko1056 Item GroupNone Incorrect Result
        Release5.1.0 6.0.90
    2020-03-05 mtmiller StatusWorks For Me Need Info
    2019-10-31 None Attached File- Added loose.eps, #47774
    2019-10-31 pantxo Attached File- Added loose.eps, #47772
        Attached File- Added tight.eps, #47773
        CategoryOctave Function Plotting with OpenGL
        StatusNeed Info Works For Me
    2019-10-30 pantxo StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code