Ghostscript rotate image 90 degrees

I am using Ghostscript to convert a PDF to a PNG.  When I convert it I would like to rotate it 90 degrees because on the SSRS report I am inserting it into I need it to display "vertically" rather than horizontally.  Is there any way of to do this in Ghostscript?
maverick0728Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joe Winograd, Fellow&MVEDeveloperCommented:
There's no easy way that I'm aware of to rotate it with Ghostscript while converting it to PNG. But if you're satisfied with the PNG that Ghostscript creates from the PDF, then I suggest using another command tool to rotate the PNG after Ghostscript creates it. Personally, I'd use the Xpdf command line utility PDFtoPNG to convert it from PDF to PNG, but if you're happy with Ghostscript doing it, that's fine, too.

 Here are three choices:

(1) IrfanView: While most folks are familiar with the IrfanView GUI, what's less well known is that it has a CLI. Here's the call to rotate your PNG right:

i_view32.exe input.png /rotate_r /convert=input.png

That will modify the input file. If you prefer to create a new output file and not modify the input file, do this:

i_view32.exe input.png /rotate_r /convert=output.png

Likewise, here are the calls to rotate your PNG left:

i_view32.exe input.png /rotate_l /convert=input.png
i_view32.exe input.png /rotate_l /convert=output.png

(2) GraphicsMagick: I have written several articles here at Experts Exchange about GraphicsMagick:
Reduce the file size of many JPG files in many folders via an automated, mass, batch compression method
Create a PDF file with Contact Sheets (montage of thumbnails) for all JPG files in a folder and each of its subfolders using an automated, batch method
Create an image (BMP, GIF, JPG, PNG, TIF, etc.) from a multi-page PDF
Convert a multi-page PDF file into multiple image files

The first one is important for you because it explains the download and installation of GM and discusses its various versions. The other articles I show just as reference material in case you are interested in seeing some of its features in action. However, none of the articles shows exactly what you want to do, so I'll explain that here. The call to rotate right is this (90, of course, is the degrees):

gm.exe convert input.png -rotate 90 input.png

That will modify the input file. If you prefer to create a new output file and not modify the input file, do this:

gm.exe convert input.png -rotate 90 output.png

Likewise, here are the calls to rotate your PNG left (-90 degrees instead of +90):

gm.exe convert input.png -rotate -90 input.png
gm.exe convert input.png -rotate -90 output.png

(3) ImageMagick: I prefer GraphicsMagick over ImageMagick, but both are excellent (GM is a fork of IM). One advantage of ImageMagick is that it's easier to incorporate its CLI into a program, as it is completely stand-alone. The calls are identical to GM, namely:

magick.exe convert input.png -rotate 90 input.png
magick.exe convert input.png -rotate 90 output.png
magick.exe convert input.png -rotate -90 input.png
magick.exe convert input.png -rotate -90 output.png

Regards, Joe

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Images and Photos

From novice to tech pro — start learning today.