PDF to JPEG Conversion - Image Quality is Poor

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

Moderators: XnTriq, xnview

Post Reply
ap2010
Posts: 4
Joined: Tue May 27, 2014 2:36 pm

PDF to JPEG Conversion - Image Quality is Poor

Post by ap2010 »

Hello,

We are using nConvert utility to convert PDF and Adobe Illustrator (AI) files to JPEG using these commands.

commands -

nconvert -out jpeg -truecolors *.ai
nconvert -out jpeg -truecolors *.pdf

But the generated image is not of good quality. Attached is the sample PDF file.
a.pdf
Sample PDF File
(1.88 MiB) Downloaded 189 times
Can you please guide us if we are missing any nconvert parameters so that the output image quality will be good.

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

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by cday »

The default Ghostscript DPI is 72, so you need to set a higher value; adding the following term sets the DPI at 300, which may be a more suitable value:

Code: Select all

-dpi 300
Edit:

The sample PDF file a.pdf you uploaded has a DPI value of 300, so that looks like a good value to use.
ap2010
Posts: 4
Joined: Tue May 27, 2014 2:36 pm

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by ap2010 »

Thanks for the reply. I tried with following option -

nconvert -dpi 300 -truecolors -out jpeg *.pdf

But its not giving proper image quality (slightly better than non-dpi option). I am attaching the JPEG image generated with above command. Generated JPEG image is still missing those glossiness.

Can you please guide me for some other option? Any help in this is highly appreciated.

Thanks.
Attachments
Generated JPEG Image
Generated JPEG Image
cday
XnThusiast
Posts: 2706
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by cday »

Confusingly, your exact script works for me:
a_cday.jpg
Inspecting my image a_cday.jpg in XnView (the windowed program), the DPI is shown as 300 and the pixel dimensions are 2549 x 3299 px, whereas for your a_2.jpg image the DPI displays as ??? and the pixel dimensions are 495 x 640 px.

So it looks as if the DPI term in the script has not operated correctly on your computer: are you using Windows with Ghostscript installed, x32 for NConvert x32 or x64 for NConvert x64?

In addition, your source PDF opens normally in Adobe and XnView software, but in NitroPro it is displayed with a purple colouration, so there might also be an issue of some kind with the source file; the file properties indicate it was produced with Adobe Illustrator CS6, so that is perhaps more likely a NitroPro issue, although possibly it is a pointer to a subtle issue with the source file.
ap2010
Posts: 4
Joined: Tue May 27, 2014 2:36 pm

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by ap2010 »

Hello,

I am using Windows 64 bit software from nConvert and GS.

Here is the exact command output -

E:\NConvert-win64\XnView>nconvert -dpi 300 -truecolors -out jpeg *.pdf
** NCONVERT v6.70 (c) 1991-2015 Pierre-E Gougelet (Feb 18 2015/16:46:22) **
Version for Windows Xp/Vista/7 x64 (All rights reserved)
** This is freeware software (for non-commercial use)

GS: (C:\Program Files\gs\gs9.16\bin\gsdll64.dll)
ARG 0 -dNODISPLAY
ARG 1 -dQUIET
ARG 2 -sPDFname=a.pdf
ARG 3 -sDSCname=C:\Users\oej\AppData\Local\Temp\x_D7E8.tmp
ARG 4 pdf2dsc.ps
ARG 5 -c quit
==> 102
ERROR: -101
GS: (C:\Program Files\gs\gs9.16\bin\gsdll64.dll)
ARG 0 -dBATCH
ARG 1 -dFirstPage=1
ARG 2 -dLastPage=1
ARG 3 -dMaxBitmap=300000000
ARG 4 -sDEVICE=tiff24nc
ARG 5 -q
ARG 6 -dNOPAUSE
ARG 7 -dSAFER
ARG 8 -dTextAlphaBits=4
ARG 9 -dGraphicsAlphaBits=4
ARG 10 -g2549x3299
ARG 11 -r300x300
ARG 12 -sOutputFile=C:\Users\oej\AppData\Local\Temp\x_D827.tmp
ARG 13 a.pdf
ARG 14 -c quit
ARG 15 -c quit
==> 220
GS>Conversion of a.pdf into a_4.jpg OK

E:\NConvert-win64\XnView>



-----

I am not sure about the first error from above output.
ERROR: -101


Can you please guide me what is wrong here?

Appreciate your feedback.

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

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by cday »

Comparing your command output with mine, firstly I also have ERROR: -101 so that likely isn't relevant, and secondly your ARG 10 image dimensions and ARG 11 DPI are in fact correct: I made the mistake of downloading your output image from the image displayed in your post, rather than the full size image displayed when the image is clicked...

The difference between my image and your image therefore seems to be the colouration:
Image_1.jpg
So some progress, but I don't immediately have any further suggestions; I copied and pasted my command line directly from your post, and that is exactly the code you are running?

Possibly someone else can identify the issue, which can probably as well be investigated in one of the XnView windowed image programs in the first instance... :?:
cday
XnThusiast
Posts: 2706
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by cday »

Standby: looks like a Ghostscript or possibly NConvert version issue, as I have now reproduced your image using NConvert 6.70 x64 and Ghostscript 9.16...

My original tests used older x32 versions of both programs, but I have now produced correct output using NConvert 6.70 x64 and an older Ghostscript version, but I'm running out of time and mental energy to investigate further at the moment. Perhaps you can do some systematic tests using earlier versions? :wink:
cday
XnThusiast
Posts: 2706
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by cday »

Update: The colourisation issue seems to be specific to Ghostscript 9.16, supposedly only a minor update...

If you uninstall 9.16 and install Ghostscript 9.15 your code should, with luck, work as intended. :D

http://www.ghostscript.com/GPL_Ghostscript_9.15.html
ap2010
Posts: 4
Joined: Tue May 27, 2014 2:36 pm

Re: PDF to JPEG Conversion - Image Quality is Poor

Post by ap2010 »

Hello,

Yes, There seems to be some regression with ghostscript version 9.16 and it works with earlier version. I need to check with Ghost script what is exactly wrong there.

Appreciate your feedback and quick analysis comments.

Thank you.
Post Reply