Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am converting images to PDFs. I use following command

convert page.jpg page.pdf

and then combine multiple PDFs generated accordingly by command

pdftk 1.pdf 2.pdf output result.pdf

but I noticed loss of quality in the resulting PDF. Is there some way that I can retain the quality of the PDF i. e. I want the same quality in PDF as in the image.

I am not sure if this convert command is using the imagemagick library. Is there any better solution? I have 100s of PDFs, so I have to do it via command line.

share|improve this question
1  
I've always dragged images into a blank LibreOffice Writer page, then exported the page as a PDF. Can you try this and see if this gives you the result you want? –  Tom Brossman Jan 13 '12 at 11:00
    
I think you need to add the -quality switch to the convert command? I don't think pdftk does any resampling on its own. I.e. convert page.jpg -quality 100 page.pdf –  bkzland Jan 13 '12 at 11:47
    
Another way is to install a pdf printer and print it to this one. –  Michael K Jan 13 '12 at 11:48
1  
I don't have this issue with convert, or I don't notice it. Could you explain in detail the loss of quality or provide an example? –  steabert Jan 13 '12 at 12:55
    
@steabert check install cups-pdf in your machine. Now check this link futuresamachar.com/index.php?url=view/2007/February and via the web interface go to page 13 take a printout of as a pdf as softcopy.Now go to this link image.issuu.com/110829052101-b15e7acd36244915b721c47cc572dab2/jpg/page_13.jpg and use your convert method.You will notice the difference. –  Registered User Jan 13 '12 at 15:17

3 Answers 3

Although the author of the question specifies the need to use command line because of the high number of image files, I have to say that the comment made by Tom Brossman related to LibreOfficeWriter is the best answer to the question, because it includes the solution to a nasty problem (presented below) that may appear especially when dealing with many images.I stumbled upon this problem and tried a few options - from the Termial, using Gimp and such, and using the 'printing as file' feature, but have to conclude that the 'drag and drop'+'Export as PDF' in LibreOfficeWriter is the best, because:

1) you can already see before exporting images as pdfs if there are any differences between these images as they will appear in the final pdf. What I mean is that despite similar sizes in bytes and aspect ratio, when importing jpeg-s or png-s into a pdf, some pages may appear much smaller than the others, without any difference in quality in fact, but just because they seem to be 'focused' differently and displayed at a different scale. (I cannot understand the cause of this and welcome a comment that would enlighten me, I just stumbled into this when putting very similar images into a pdf file, as seen below.)

enter image description here

When looking at the images before converting them into a pdf, you cannot anticipate this error, but LibreOfficeWriter makes it visible and also very easy to correct: just grab the margin of the image, put it into the appropriate form into the page, and it will appear as such in the final pdf.

enter image description here

2) And, when exporting ('File'- 'Export as PDF...') you have several options that let you control the final quality/size of the pdf, which could be very useful if you need to send it by mail and still keep some image quality.

enter image description here

share|improve this answer

I dont know if this is definitely the answer to your question as i am not used to the convert program. PDF is not an image file format, its is a way of formatting documents so that they can be represented consistently not matter what hardware/software you are viewing it from. Therefore when you "convert" the image from JPEG to PDF the JPEG is not actually being converted. The JPEG is embedded in the PDF file itself and the PDF file tells your document viewer how to display the contents on the screen/page.

I imagine the loss of quality you are seeing is because of the program with which you are viewing the files. When you view the jpeg with GNOME image viewer the image is displayed exactly as it should be, say and 800x600px image is layout out perfectly on 800x600 pixels on the screen. But when you open your PDF in Document Viewer the viewer lays the 800x600px image out over maybe 25x15cm (or whatever) of the document which when viewed at 100% may not be exactly 800x600 pixels of screen space, it may be more therefore stretching the image and reducing the quality.

share|improve this answer

Based on your comment I tried the links and I see what the problem is. You issue is with the heavy compression that Issuu applies to the pages, and with the Flash interface used to display the page as a lossy image.

Your conversion of images to PDF is just fine, the quality loss is occurring when Issuu converts your PDF to their proprietary Flash format and serves it up on the site.

share|improve this answer
    
infact the flash interface which they are using if you take a printout from it gives a pdf worth 600 K and if you take a printout of image via convert is 400K.What you said I had understood.The quality of pdf generated via their viewer is better than the one I have by converting the image to pdf using imagemagick.But is there a way out there so that I retain the quality of pdf. –  Registered User Jan 13 '12 at 15:47
    
Now I think I get your problem. Yes the printed pdf from the flash interface has the characters in vector format. But I still don't know what's the deal with the jpg image, what exactly are you trying to do?? –  steabert Jan 13 '12 at 15:52
    
@steabert I am just trying to understand image manipulation tools a bit better.How does one get to know various parameters like dpi,density or other things of a pdf or jpg and then compare them with different conversion programmes.I am trying to compare different programmes as how effective different programmes are.A comparison of properietary and open source tools kind of study.Where do these difference come in etc etc. –  Registered User Jan 13 '12 at 15:57
    
That's nice, but not your original question. Programs themselves have nothing to do really with the image quality, that is determined by the resolution, the format (lossy, lossless), and the rasterization algorithms (vector to bitmap). Read this one: azglassclasses.com/Tutorials/RasterVector –  steabert Jan 13 '12 at 16:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.