I want to use GS to generate thumbnails from pdf files.
- The thumbnail must fit a 90x120 pixel rectangle
- The image should not be rotated
- The image should be resized to fit the rectangle with keeping aspect ratio
I use the following command:
gswin32 -dPDFFitPage -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT
-dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0
-dDEVICEWIDTH=90 -dDEVICEHEIGHT=120 -dORIENT1=true
-sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4
-sOutputFile=output.%d.jpg input.pdf
Result:
If I use some PDF with portrait pages like this example, which you can download, then the thumbnail is correct, as you can see here:
If I use it for a PDF with landscape pages, the devicewidth is taken as height somehow:
How can I prevent this behaviour? I want my Porsche to be 90x120 as well. I think maybe i need to provide some Postscript code for Ghostscript (with -c command line argument), but I have no experience with that. Could someone please help me?
EDIT1: I tried the suggestion of KenS. With the -dFIXEDMEDIA my porsche gets cropped like you can see below:
EDIT2: first solution of Kurt Pfeifle is not ok for portrait images (white part right side, not using space properly). See below:
EDIT3: third solution of Kurt Pfeifle is almost good. For landscape images its perfect:
However, the portrait pages have sizing problems, and the background becomes completely gray as well:
So Kurt, i think I could split the pdf to pages (with GS -dFirstPage and -dLastPage), and then if you have some idea, how to decide if a page is landscape or portrait, then I could do some conditional processing. Any idea? As for background color, I think its not that important, but if you have ideas here as well, then they are welcome.