bugGNU Octave - Bugs: bug #49698, Setting PNG output resolution and...

 
 

bug #49698: Setting PNG output resolution and size in print command overwrites resolution

Submitted by:  None
Submitted on:  Fri 25 Nov 2016 09:08:32 AM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: ConfirmedAssigned to: None
Originator Name: WysiOriginator Email: -unavailable-
Open/Closed: OpenRelease: 4.2.0
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 26 Nov 2016 04:06:32 AM UTC, comment #3:

This probably indicates the fix needs to be devised more carefully and it needs to be tested on multiple operating systems and multiple versions of ghostscript, etc. On my computer I needed to modify the canvas size in order to get 800x500 output. On your computer, that was not the case.

Rik <rik5>
Project Administrator
Fri 25 Nov 2016 02:40:11 PM UTC, comment #2:

Thank you. I quickly tested it, the result is as attached: Now resolution is correct, but canvas size is not the original input size.

In my example code below (and on my Windows machine), the original canvas size of [800,500] is changed to

[800,500]/600*72 = [96,60]

Instead, I'd prefer to keep [800,500].

Suggestion: Only change resolution if not specified as input:

E.g.

if ~any(cellfun(@any,strfind(varargin,'-r'))) % add: if '-r' option is set, do not overwrite
arg_st.ghostscript.resolution = 72;
end % add

(file #39069)

wysi <wysi>
Fri 25 Nov 2016 12:57:03 PM UTC, comment #1:

Confirmed. The attached diff seems to fix the issue for me.

(file #39068)

Rik <rik5>
Project Administrator
Fri 25 Nov 2016 09:08:32 AM UTC, original submission:

Task: Saving a figure to .png as it appears on the screen, using both size and resolution options (e.g. -S800,500, -r600).
Result: While both Options alone work, setting them together overwrites the rsolution with 72.

Example code:

figure(1,'Position',[100,100,800,500]);
plot(randn(100,2))
title('test'); ylabel('y axis'); xlabel('x axis');
pos=get(gcf,'Position');
print('-dpng', 'test.png', '-r600',['-S',num2str(pos(3)),',',num2str(pos(4))]);

The output is of very much lower resolution, probably 72 (cf. below).

The problem may be related to code in the function scripts/plot/util/private/__print_parse_opts__.m, where it says around line 367:

arg_st.ghostscript.resolution = 72;

Simply commenting out this line, the output looks as expected. However, this is probably not the solution for all cases.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #39069:  test.png added by wysi (32KiB - image/png)
file #39068:  printsz.diff added by rik5 (1KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by wysi (Updated the item)
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 25 Nov 2016 02:40:11 PM UTCwysiAttached File-=>Added test.png, #39069
    Fri 25 Nov 2016 12:57:03 PM UTCrik5Attached File-=>Added printsz.diff, #39068
      StatusNone=>Confirmed
      Release4.0.3=>4.2.0
      Operating SystemMicrosoft Windows=>Any

    Back to the top


    Powered by Savane 3.1-cleanup1