Converting PDF to TIFF and losing orientation

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
traviscsb
Posts: 4
Joined: Fri Dec 06, 2013 7:45 pm

Converting PDF to TIFF and losing orientation

Post by traviscsb » Fri Dec 06, 2013 7:49 pm

Hello,

I'm having a problem with a command line nconvert while trying to convert a PDF to TIFF. The PDF in question is already formatted in landscape orientation, but for some reason when I run the nconvert command, the resulting Tiff is produced in portrait orientation, causing part of the image to get cut off. Any thoughts?

Code: Select all

nconvert -in pdf -out tiff -c 3 -o tif/13-42777-08003.TIF pdf/13-42777-08003.pdf

cday
XnThusiast
Posts: 1987
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Converting PDF to TIFF and losing orientation

Post by cday » Fri Dec 06, 2013 10:50 pm

The following code works for me with a test landscape image I created -- I'm unable to reproduce the problem you describe:

Code: Select all

nconvert -dpi 300 -out tiff -c 3 -o Landscape.tiff Landscape.pdf
Notes:

-in isn't required but does no harm;

-dpi is required unless the default Ghostscipt DPI of 72 is satisfactory;

You do have Ghostscript installed, x32 or x64 to match the version of NConvert installed?

Presumably you're not running NConvert under Windows with the '/' s in your script?

If you're unable to find the problem, could you post an image that illustrates the issue (<256KiB and zip'd) or upload one to a file hosting service?

traviscsb
Posts: 4
Joined: Fri Dec 06, 2013 7:45 pm

Re: Converting PDF to TIFF and losing orientation

Post by traviscsb » Thu Dec 12, 2013 6:57 pm

I am working via the command line in windows. The actual conversion works just fine with the caveat that it doesn't seem to be keeping orientation of the original image.

I actually did not have Ghostscript installed. What function does that provide? I did attempt to install it after I read your reply, but when running my Nconvert script after that installation I received the following error: Error: Don't know how to read this picture (pdf/Test.pdf). By uninstalling Ghostscript I was able to get it to run again, but still having the issue with orientation. Here is the resulting Image:
http://imgur.com/SQc0C8m

cday
XnThusiast
Posts: 1987
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Converting PDF to TIFF and losing orientation

Post by cday » Thu Dec 12, 2013 9:14 pm

Ghostscript is normally required to rasterise an image contained in a PDF file so that it can be displayed as an image on the screen, and the DPI setting used for the rasterisation determines the pixel dimensions of the resulting image and hence its quality -- too low DPI results in a poor quality image. AFAIK Ghostscript is required when using NConvert to extract an image from a PDF file and save it as a TIFF or PNG, so your reported results are unexplained at the moment.

The image link you posted is to a portrait orientation PNG file presumably showing the incorrect output you're obtaining, could you upload the source landscape PDF file it was produced from, or other landscape PDF showing the problem, for examination and test?

traviscsb
Posts: 4
Joined: Fri Dec 06, 2013 7:45 pm

Re: Converting PDF to TIFF and losing orientation

Post by traviscsb » Tue Dec 17, 2013 1:48 pm

https://drive.google.com/file/d/0B0EjSW ... sp=sharing

Let me know if you can't get to this test file.

With regard to the Ghostscript question - I'm not sure. I've validated that I don't have it installed, but NConvert seems to be converting the PDF to TIF with no issues, it just doesn't persist the orientation.

A bit more background information - I was using Windows XP when I had this all working correctly. I've since upgraded to Windows 7. I'm not sure if that makes a difference or not. Thanks again!

cday
XnThusiast
Posts: 1987
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Converting PDF to TIFF and losing orientation

Post by cday » Wed Dec 18, 2013 2:23 pm

Thanks for uploading your test file Test.pdf whick I've now successfully downloaded.

I can confirm that your file converts normally to a TIFF on my computer using the script I posted above. As the resulting file extracted at 300dpi is too large to upload to the forum, I've also converted it at 72DPI using this script:

Code: Select all

nconvert  -dpi 72 -out tiff -c 3 -o Test_72DPI.tiff Test.pdf
This is the resulting TIFF file:
Test_72DPI.tiff
(49.34 KiB) Downloaded 101 times
Your test file reproduces quite well at 72DPI, but very often conversion at a higher DPI is required to obtain a good quality image -- if you try converting your file at 300DPI and compare the TIFF images obtained you will notice that at the higher resolution the image is slightly sharper.
traviscsb wrote: A bit more background information - I was using Windows XP when I had this all working correctly. I've since upgraded to Windows 7. I'm not sure if that makes a difference or not. Thanks again!
If you were using Windows XP x32, you must have have been using NConvert x32 and presumably had Ghostscript x32 installed -- Ghostscript normally installs to a folder 'GS' in the Programs folder. The test PDF image you uploaded was in fact created using an application that uses Ghostscript, as shown in the file properties in a PDF viewer: File > Properties (Ctrl - D).

Under Windows 7 -- presumably x64 -- you can use either NConvert x32 or x64 -- if you install x32 you require Ghostscript x32 which normally installs to Program Files (x86), and if you install x64 you require Ghostscript x64 which normally installs to Program Files. I'm running Windows 7 x64, so if it works on my computer it should work on yours...

The results you have previously obtained are unexplained but conceivably running NConvert with the wrong version of Ghostscript might result in only half the PDF image being extracted and the page orientation defaulting to U.S. Letter size in portrait orientation, as in the original image you uploaded -- I don't know without trying it!

Edit:

If you're still unsure whether you have Ghostscript installed or not, you might also look in the Control Panel > Programs listing of installed software as it may be easier to recognise there.

You might also simply install both x32 and x64 Ghostscript versions, as I have on my computer, and then whichever version of NConvert you are using should automatically find the correct version of Ghostscript.

traviscsb
Posts: 4
Joined: Fri Dec 06, 2013 7:45 pm

Re: Converting PDF to TIFF and losing orientation

Post by traviscsb » Tue Dec 24, 2013 4:07 pm

I went through and completely uninstalled everything. Installed nconvert and installed both the 32 and 64 bit versions of ghostscript and everything seems to be working correctly now. Still not 100% sure what it was, but I'm guessing you were correct in thinking that the versions were not matching up.

Thank you so much for your help!

Post Reply