Bug 702607 - DEVICEWIDTHPOINTS < DEVICEHEIGHTPOINTS produces empty PNG image
Summary: DEVICEWIDTHPOINTS < DEVICEHEIGHTPOINTS produces empty PNG image
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: 9.52
Hardware: PC Linux
: P4 normal
Assignee: Ray Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-01 16:35 UTC by Werner Lemberg
Modified: 2020-10-28 05:03 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Input test file. (147.45 KB, image/x-eps)
2020-08-01 16:35 UTC, Werner Lemberg
Details
PNG test output. (4.68 KB, image/png)
2020-08-01 16:36 UTC, Werner Lemberg
Details
Patch (2.82 KB, patch)
2020-08-05 16:04 UTC, Peter Cherepanov
Details | Diff
A patch with optional rotation (2.88 KB, patch)
2020-08-05 17:19 UTC, Peter Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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'?