bugGNU Octave - Bugs: bug #55907, png plot does nor respect dpi and...

 
 

bug #55907: png plot does nor respect dpi and produces unreadable results

Submitter:  None
Submitted:  Wed 13 Mar 2019 08:45:37 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Octavian Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 30 Mar 2019 04:03:50 AM UTC, comment #5: 

I checked in a changeset that uses a correct scale factor for the fonts when the -S size option is present.  See https://hg.savannah.gnu.org/hgweb/octave/rev/dd31206c87c0.  This changeset also emits a warning if the -S option and -r option are both present.

This will be part of the 6.1.0 release.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Thu 21 Mar 2019 11:11:25 PM UTC, comment #4: 

Quotes are needed to prevent the comma from being parsed as starting a new command. This creates a png file and does not raise any error or warning:


clear all
close all
sombrero
print -dpng ./MyPlot.png "-S4000,3000" -r1000


The result is the same whether the -r option is present or not, so the last comment seems to be accurate, the -r option is ignored if -S is present. The help could be improved, also a warning could be printed if both options are present and the -r option is ignored.

Mike Miller <mtmiller>
Group Member
Fri 15 Mar 2019 03:32:56 PM UTC, comment #3: 

Are you saying that you don't get an error when you run the print command?


clear all
close all
sombrero
print -dpng ./MyPlot.png -S4000,3000 -r1000


If so, that is a different issue to debug.

The "-r" and "-S" options are for different things.  The "-r" option sets the resolution (DPI).  It does not set the size of the figure.  If you want a particular output size, use the paperXXX properties.  See Matlab documentation (https://www.mathworks.com/help/matlab/ref/print.html) for which Octave has to maintain compatibility.

The "-S" option is for setting the size of the output in pixels.  Normally, the number of pixels would be determined automatically by Octave as 


number of pixels = physical_size (in inches) * DPI


But by using the "-S" option you have explicitly said how many pixels you want and the resolution is irrelevant.  It's not an error to specify the two options together, although maybe a warning would be useful that the "-S" option takes precedence.

If this is unclear, you could suggest help text for the print command that would better document it.

Rik <rik5>
Group administrator
Fri 15 Mar 2019 08:47:34 AM UTC, comment #2: 

You get no error message in a Script.
As seen in the documentation, it is equivalent! But it isn't, so it is an error.


https://octave.org/doc/v4.2.2/Printing-and-Saving-Plots.html
-rNUM

    Resolution of bitmaps in pixels per inch. For both metafiles and SVG the default is the screen resolution; for other formats it is 150 dpi. To specify screen resolution, use "-r0".

-Sxsize,ysize

    Plot size in pixels for EMF, GIF, JPEG, PBM, PNG, and SVG. For PS, EPS, PDF, and other vector formats the plot size is in points. This option is equivalent to changing the size of the plot box associated with the "paperposition" property. When using the command form of the print function you must quote the xsize,ysize option. For example, by writing "-S640,480".


Why should this not work on a png-file as documented?

Okti <oktopus>
Wed 13 Mar 2019 06:44:23 PM UTC, comment #1: 

The sample code does not execute correctly.


octave:4> clf
octave:5> sombrero
octave:6> print -dpng ./MyPlot.png -S4000,3000 -r1000
error: 'r1000' undefined near line 1 column 43


What Octave probably did was produce a plot of the desired size, but the resolution argument was ignored so it used screen resolution of ~96 DPI.  This would certainly make any fonts appear very, very small (~100/1000 or 10% of normal).

If you want to set the size of an image for printing use the paperXXX properties of the figure object.


paperorientation
paperposition
papersize
papertype
paperunits


The properties are inter-related so setting something like "papertype" to "usletter" will automatically set the "papersize".

From the command, I think you were trying to get a 4"x3" image at 1000 DPI.  To do that, set the size for printing and then issue the print command.


set (gcf, "paperunits", "inches", "paperposition", [0, 0, 4, 3]);
print -r1000 MyPlot.png



Rik <rik5>
Group administrator
Wed 13 Mar 2019 08:45:37 AM UTC, original submission:  

Plotting under 5.1 does work to png-images. The image is not empty and the drawing looks like expected. But the font size does not scale als the drawing does, so it is unreadable.

Plot an image with 4000x3000 pixel und 1000dpi for high resolution printing on a printer:
print -dpng ./MyPlot.png -S4000,3000 -r1000

The error is already found in 4.4.

Anonymous

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-30 rik5 StatusWorks For Me Fixed
        Open/ClosedOpen Closed
        Release5.1.0 dev
        Operating SystemMicrosoft Windows Any
    2019-03-13 rik5 StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code