bugGNU Octave - Bugs: bug #53535, print with eps driver should use...

 
 

bug #53535: print with eps driver should use '-tight' bbox by default for Matlab compatibility

Submitter:  Hugo Raguet <snake>
Submitted:  Sat 31 Mar 2018 06:51:19 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.2.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 05 Dec 2018 11:30:41 PM UTC, comment #7: 

I worked out the issues in _print_parse_opts_.m and I collapsed the structure variables "loose" and "tight_flag" in to just one variable "tight".  I changed the documentation and made tight the default.  See changeset https://hg.savannah.gnu.org/hgweb/octave/rev/0a145a1600e3.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Fri 20 Apr 2018 03:56:23 AM UTC, comment #6: 

I missed your comment below:

===========================
However, the loose option is used to set a different option in
_print_parse_opts_.m.


    if (arg_st.formatted_for_printing)
      arg_st.ghostscript.epscrop = ! arg_st.loose;
    else
      ## pstoedit throws errors if the EPS file isn't cropped
      arg_st.ghostscript.epscrop = true;
    endif


I'm not sure why there are two options and whether they can be safely
collapsed in to one.
============================

This (-loose) is not documented, but also appears only to apply to EPS.
And, it is unclear what if anything it does.

So, my previous comment still applies.

Michael Godfrey <godfrey>
Group Member
Fri 20 Apr 2018 03:48:25 AM UTC, comment #5: 

Rik: It seems reasonable to apply -tight to all
formats that have bounding boxes. -tight should
mean minimum bounding box, as it does in the code below.

-loose is currently undefined. It might be better
to replace it with an option which sets the bounding
box. Say,

-bbox "<left> <bottom> <right> <top>"                       ()
                      override bounding box found by ghostscript
                      with origin at the lower left corner

This is just copied from the pdfcrop -help

Michael Godfrey <godfrey>
Group Member
Mon 16 Apr 2018 10:11:15 PM UTC, comment #4: 

Rik: Seems right to me.

The following code does the setting tight BB:
  print (outfile, "-color");
  close (gcf ());     %% ensure that figure is written to PDF
  cropcmd = ["pdfcrop " outfile " " outfile];
  system(cropcmd);

"pdfcrop" is the script that does the work. It is available
from Sourgeforge and is just a pearl script which calls gs.
The version I used can be downloaded from:

https://sourceforge.net/projects/pdfcrop/files/

Michael Godfrey <godfrey>
Group Member
Mon 16 Apr 2018 09:41:29 PM UTC, comment #3: 

Matlab only defines -tight for eps and ps output, but given how closely related pdf is, it seems like it would be reasonable to extend it to that format as well if possible.

Rik <rik5>
Group administrator
Mon 16 Apr 2018 09:33:59 PM UTC, comment #2: 

It seems that it would be very helpful if
-tight was recognized for PDF output. Was there
a reason why it was defined for EPS only?

I agree that having -loose and -tight both
seems unreasonable.

Michael Godfrey <godfrey>
Group Member
Mon 16 Apr 2018 08:53:29 PM UTC, comment #1: 

It does look correct to make tight the default.  However, it looks to be slightly more complicated.  For unknown reasons there is both a "loose" setting and a "tight_flag" setting and it is not the case "loose" is simply the logical inverse of "tight_flag".

In print.m the tight_flag is used to decide how to invoke epstool to produce output:


    if (opts.tight_flag)
      cmd = "--copy --bbox";


However, the loose option is used to set a different option in _print_parse_opts_.m.


    if (arg_st.formatted_for_printing)
      arg_st.ghostscript.epscrop = ! arg_st.loose;
    else
      ## pstoedit throws errors if the EPS file isn't cropped
      arg_st.ghostscript.epscrop = true;
    endif


I'm not sure why there are two options and whether they can be safely collapsed in to one.

Rik <rik5>
Group administrator
Sat 31 Mar 2018 06:51:19 PM UTC, original submission:  

When printing in eps format with 'print',
Matlab uses tight bounding box by default, which can be changed by setting the '-loose' option
Octave uses loose bounding box by default, which can be changed by setting the '-tight' option.

Now, any Matlab code can be ported to Octave because the Octave also understands the '-loose' option, but I am afraid some Octave code cannot be ported to Matlab because Matlab does not know any '-tight' option.

It would be nice if code I write for Octave could be directly run by potential Matlab users, without having to test for wether its Matlab or Octave being run and duplicating code.

As a side note, the tight behavior really should be the default, in most case the loose bounding box is arbitrary and is not satisfying.

Attached is a very simple patch.

Hugo Raguet <snake>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #43748:  print_eps_tight_doc.patch added by snake (781B - text/x-patch - modify the 'print' doc accordingly)
file #43745:  print_eps_tight.patch added by snake (782B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by snake (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-05 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-04-16 rik5 StatusNone Confirmed
    2018-03-31 snake Attached File- Added print_eps_tight_doc.patch, #43748
    2018-03-31 snake Attached File- Added print_eps_tight.patch, #43745

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code