I need to take two 8.5in by 11in JPEG images and merge them together into two pages of a PDF. Is there a commandline or GUI tool for this?


As you're interested in a two-pages pdf, you can do something similar

convert input1.jpg output1.pdf
convert input2.jpg output2.pdf

The next step is to make one pdf out of it. This can be easily done with gs. As explained here: https://www.linux.com/news/software/applications/8229-putting-together-pdf-files

You can also use the imagemagick toolkit to first stitch the jpg images, which can be done from command-line only.

convert -append input1.jpg input2.jpg output.jpg
convert output.jpg output.pdf

More info http://www.imagemagick.org/script/command-line-options.php#append

|improve this answer|||||
  • 3
    what is the difference of your solution from convert intput1.jpg input2.jpg output.pdf? – pbm Mar 16 '12 at 20:59

One way is to create a LaTeX document which includes the images and in turn creates one pdf document holding both jpgs. Ruthlessly taken from another answer: you could do something like the following. Create a file image.tex with the content:


Then compile the file into a pdf document:

$ pdflatex image.tex
|improve this answer|||||
  • 1
    If the OP has to do this more often, it might be worth having a closer look at the pdfjam tools – they don't do what you'd like to achieve, but it's an example of how to create LaTeX-files on-the-fly to automate this answer into a tiny script. – sr_ Mar 17 '12 at 8:33

First create two pdfs for the two jpeg images using the OpenOffice word processor. Then you can merge the two pdfs using PDF-Shuffler.

|improve this answer|||||

More of a comment on the state of the art rather than an answer, but:

I believe using a text editor (like LibreOffice or OpenOffice.org) or a text processor (like LaTeX) to generate a pdf version of the jpeg images is a bit overkill, as it is something as simple as a single image.

OTOH convert actually converts, it does not simply put the JPEG image inside a PDF container (maybe I'm wrong here and PDF does not support JPEG streams, but I think it does), so although convert is way easier and quicker, it's still a bit overkill — ironically, maybe either LibreOffice or LaTeX actually just copy the JPEG instead of converting it (but here I'd say it's not worth the trouble).

For the joining step, you can either use, as already pointed out, gs. There is also pdftk, which, IIRC, just glues the PDFs together (gs will read the PDFs and render a new pdf out of it (at least when used with pdfwrite, you're free to generate, e.g., a postscript file instead, although that's of little use here).

|improve this answer|||||
  • 1
    Here the syntax for pdftk: pdftk img1.pdf img2.pdf output all.pdf – jofel Mar 16 '12 at 23:42
  • And if you can't use pdftk (e.g. on fedora 21), qpdf --empty --pages 1.pdf 2.pdf -- all.pdf. – Nemo Oct 5 '15 at 8:14

This is also a solution https://stackoverflow.com/questions/4283245/using-ghostscript-to-convert-jpeg-to-pdf.

But it seems that the original JPEG's might be altered.

|improve this answer|||||
  1. Create a new folder, add them to this folder and make sure they have a .jpg file ending (case might matter)
  2. Go to that folder and type in terminal convert *.jpg output.pdf

This works with as many JPGs as you want. You will get one n-pages PDF-file for n JPG-files.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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