Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have many jpeg files in a directory, and I want to convert them to pdf and concatenate them together to make a document. How can it be done? I'd prefer the command line, as it will be faster.

share|improve this question

7 Answers 7

From the imagemagick package, use the convert command:

convert *.jpg pictures.pdf

You will get a single pdf containing all jpg in the current folder.

Install IM with:

sudo apt-get install imagemagick

source: stackoverflow

share|improve this answer
Wow, this is soooo convenient! –  king_julien Apr 19 '14 at 21:39
@lovespeed Why has this answer not been accepted? –  MrHug Oct 7 '14 at 20:45
Using the joker didn't work for me, I had to use @Alex's solution. –  Eusebius Sep 11 at 9:31

Worked for me (BUT warning! turns off compression and resulting PDF will be big!):

convert page1.jpg page2.jpg +compress file.pdf

or even:

convert -rotate 90 page\*.jpg +compress file.pdf

From, the +compress helps it to not hang. NOTE: the +compress turns off compression. The machine I was working on at the time seemed to hang ?forever?(I did not wait forever though to find out.) without the +compress option. Your Mileage May Vary quite a bit! RTFM on option -compress, maybe experiment with -compress < type> if you have slow compression/hanging problems to find out what will work for you.

share|improve this answer
Do NOT use the +compress option with the convert command as suggested above! It actually disables all compression leaving you with a PDF 10 times bigger than the original JPEG. Just don't specify compression options, and convert will go with the input compression format (JPEG) which in this case is the best option file size-wise. Source: –  user335432 Oct 7 '14 at 20:25
That is not intuitive! Thanks S Minddal. That did work for me. I presume the machine I was using had a problem doing the compression then. I will adjust answer. –  gaoithe Oct 8 '14 at 14:31
so $ converet *.jpg file.pdf worked well with smaller file size than with +compress argument –  doctorate Sep 1 at 18:02
convert `ls -1v` file.pdf
  • This ls will list one file a time in a "natural order" (1,2,3...) and proceed with conversion.
share|improve this answer
Just what I was looking for to convert scanned images of an old book to a PDF version. –  eshwar Apr 9 at 5:08

Open jpg or png file with LibreOffice Writer and export as PDF.

I hope, this is simple way to export pdf.

share|improve this answer
Yes! LibreOffice is the best way to export image files to PDF. We have full control of the PDF output, including page layout, resizing of imported files, optional headers and footers e more... Many thanks to user359154 for the clever suggestion! –  user371260 Jan 22 at 16:59

Most of the time I use althought im looking for a local program as I dont have internet all the time... Someone got a clue?

share|improve this answer

I have used The positive thing that you can provide (the same site but different page) an archive of images and concatenate them to the common pdf

share|improve this answer

Here is a bit more sophisticated approach that

  • Allows all images to have different dimensions, while keeping the output PDF page size the same (A4 in the example below).
  • Centers the images on the PDF page.
  • Allows you to add a minimum border between images and PDF page border, to allow printing the PDF without problems.
  • Does not change the image data. (Image quality will not change, and the PDF file will have about the same file size as the image. Also you can extract the images later from the PDF without quality loss or other issues, using something like pdfimages.)


  1. Use my script from this answer to convert each image into its own one-page PDF file with A4 page size and 5% border all around.
  2. Concatenate all your one-page PDF files with PDFtk as follows:

    pdftk *.pdf cat output out.pdf
share|improve this answer

protected by Community Jan 22 at 17:08

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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