Bug 702607

Summary: DEVICEWIDTHPOINTS < DEVICEHEIGHTPOINTS produces empty PNG image
Product: Ghostscript Reporter: Werner Lemberg <wl>
Component: GeneralAssignee: Ray Johnston <ray.johnston>
Status: RESOLVED FIXED    
Severity: normal CC: sphinx.pinastri
Priority: P4    
Version: 9.52   
Hardware: PC   
OS: Linux   
See Also: https://bugs.ghostscript.com/show_bug.cgi?id=702995
Customer: Word Size: ---
Attachments: Input test file.
PNG test output.
Patch
A patch with optional rotation

Description Werner Lemberg 2020-08-01 16:35:40 UTC
Created attachment 19522 [details]
Input test file.

With the attached image `foo.eps`, calling

```
gs -sDEVICE=png16m \
   -o foo.png \
   -dDEVICEWIDTHPOINTS=600 \
   -dDEVICEHEIGHTPOINTS=601 \
   -dGraphicsAlphaBits=4 \
   -dTextAlphaBits=4 \
   -dEPSFitPage=true \
   foo.eps

```
results in an empty, framed box.  If the height is set equal to or smaller than the width, I get a properly converted image.

Is this expected?  At least while reading the documentation I couldn't find such a limitation.
Comment 1 Werner Lemberg 2020-08-01 16:36:34 UTC
Created attachment 19523 [details]
PNG test output.
Comment 2 Peter Cherepanov 2020-08-05 16:04:59 UTC
Created attachment 19539 [details]
Patch

Bug 702607: Simplify and fix a procedure that scales EPS to fit the page.

The EPS file is rotated to have the same orientation, scaled to fit the most restrictive dimension of the printable area and centred in the other dimension.
Comment 3 Werner Lemberg 2020-08-05 16:36:23 UTC
This looks great, thanks!  However, I would very much like to have an option that does *not* rotate the image.  Is that possible?
Comment 4 Peter Cherepanov 2020-08-05 17:19:03 UTC
Created attachment 19540 [details]
A patch with optional rotation

It is easy to make rotation dependent on a global flag. In this case  -dNOEPSROTATION disables rotation.

You are free to use this patch locally but I cannot guarantee that this change in Ghostscript UI will be accepted.
Comment 5 Ray Johnston 2020-08-09 05:34:46 UTC
Patch pushed. Thank you Peter. I really like the style of the implementation
and the commenting.

I am not closing this yet because we are going to discuss the option for not
rotating and we'll close it then, possibly after adding that, and also adding
it to the PDFFitPage option. We are leaning on having an option something like
AllowFitRotation that defaults to 'true', so -dAllowFitRotation=false to get
the result the submitter wants.
Comment 6 Ray Johnston 2020-10-24 19:55:37 UTC
Note there was also a later patch for bug 702995 that also affects EPS
page fitting.
Comment 7 Werner Lemberg 2020-10-28 05:03:12 UTC
Thanks a lot for fixing this!

Will the `-dNOEPSROTATION` command line option be available from now on?  Or is it replaced with '-dAllowFitRotation=false'?