I am using Ghostscript 10.02.0 to convert a PDF to a PNG with the following command:
gs -o ./test.png -dNumRenderingThreads=1 -sDEVICE=png16m -r72 -dLastPage=1 -dFitPage -dDEVICEWIDTHPOINTS=125 -dDEVICEHEIGHTPOINTS=100 -dUseTrimBox -dInterpolateControl=-1 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 ./text.pdf
The command works and converts the PDF to an image, however if the PDF has a height greater than dDEVICEHEIGHTPOINTS, Ghostscript rotates the image. I'm sure that this is because of -dFitPage however I need Ghostscript to scale the PDF (whatever size it is) to the dimensions.
I've seen in similar Ghostscript questions that -dAutoRotatePages=false is a solution however that is when creating a PDF, not an image.
Is there any way to stop Ghostscript from 'auto' rotating when converting to an image with Ghostscript arguments or do I have to modify the pdf_main.ps file to manually stop it rotating? If so, can anyone point me in the direction of what I'd need to change?
EDIT: A 'fix' for the above is to set the height and width to be the same value. That way, when ghostscript tries to fit the page, it uses the PDF orientation
After trying to get Ghostscript to stop auto-rotating when using
-dFitPage, and after I could not get the changes that @k-j and @kens gave me to work, I resorted to doing the following.I set my height and width dimensions to be equal. This meant that not matter the orientation of the PDF, I could use the fit page switch and it would keep it's orientation.
This is because the
-dFitPageswitch rotates the PDF to best fit the dimensions with as little processing power as possible. Providing it with a square means that there should be no alternative orientation that fits the PDF better.Tried and tested with multiple PDF's with varying heights and widths.
EDIT: Not marking this question as resolved/ answered as this solution is more of a 'work around' rather than a potential answer but it does solve the rotating issue