Bug 696128 - Rendering an EPS to a PNG with -dEPSFitPage and -gWxH sometimes results in blank render
Summary: Rendering an EPS to a PNG with -dEPSFitPage and -gWxH sometimes results in bl...
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Images (show other bugs)
Version: 9.16
Hardware: Macintosh Linux
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-03 14:50 UTC by a.rolek
Modified: 2015-12-04 11:15 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
EPS that is failing to render with certain device width and height dimensions (2.34 MB, application/postscript)
2015-08-03 14:50 UTC, a.rolek
Details
out.png (99.83 KB, image/png)
2015-08-03 17:23 UTC, Marcos H. Woehrmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description a.rolek 2015-08-03 14:50:07 UTC
Created attachment 11843 [details]
EPS that is failing to render with certain device width and height dimensions

When using -dEPSFitPage with -gWxH at certain dimensions the resulting rendering will be blank. Here is a fail and success command for the attached EPS file

Fails:
gs -q -dNumRenderingThreads=4 -dEPSFitPage -g1714x1713 -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=out.png steelers.eps

Works:
gs -q -dNumRenderingThreads=4 -dEPSFitPage -g257x257 -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=out.png steelers.eps
Comment 1 Marcos H. Woehrmann 2015-08-03 17:23:47 UTC
Created attachment 11844 [details]
out.png

I'm having trouble reproducing this.  With the exact command line given in the description I get the attached out.png file.  This is running Ghostscript 9.16 on a MacPro running MacOS X 10.10.4

Can you double check that the command line is correct?  Also, are all of the listed options necessary to reproduce the problem?
Comment 2 Marcos H. Woehrmann 2015-11-30 13:02:08 UTC
After trying again I'm now able to reproduce the problem with this command line, I'm not sure why I wasn't able to see it earlier:

  ./bin/gs -sDEVICE=ppmraw -o test.ppm -dEPSFitPage ./steelers.eps


It appears to be a regression, starting with:

commit d59e1feb9545b399027907cb2d1a6855c524e0b4
Author:     Ken Sharp <ken.sharp@artifex.com>
AuthorDate: Mon Feb 10 08:34:54 2014 +0000
Commit:     Ken Sharp <ken.sharp@artifex.com>
CommitDate: Mon Feb 10 08:34:54 2014 +0000

    PS interpreter - Fix rotation problem with EPSFitPage
    
    Bug #695016 "Gradient eps file to pdf"
    
    When fitting an EPS Bounding Box to a specified page size, the code looks
    at the width and height of both the page and the EPS file, to see if the
    EPS will fit 'better' by rotating it.
    
    In this particular case the page is square, but there was no special case
    for this, which mean that landscape pages wold be rotated twice, causing
    the content to disappear.
    
    This commit special cases square media sizes and does not attempt to rotate
    the EPS, no matter what its orientation, as there is clearly no point in
    doing so. This prevents the double rotation and resolves the problem.
    
    Tested with landscape, portrait and square media and EPS files, in all
    combinations.
    
    No differences expected

gs/Resource/Init/gs_epsf.ps
Comment 3 Ken Sharp 2015-12-04 09:05:31 UTC
Fixed in 44c6e3aecd4d13f47e0f75e74f63f38715ab7ab73 I believe.
Comment 4 Marcos H. Woehrmann 2015-12-04 11:15:19 UTC
I believe there is a typo in comment #3, the correct commit hash is 44c63aecd4d13f47e0f75e74f63f38715ab7ab73.