Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 to help me do this?

share|improve this question
add comment

6 Answers

up vote 7 down vote accepted

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

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

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:

\documentclass{article}
\usepackage[active,tightpage]{preview}
\usepackage{graphicx}
\PreviewMacro[{*[][]{}}]{\includegraphics}
\begin{document}
\includegraphics{img1.jpg}
\newpage
\includegraphics{img2.jpg}
\end{document}

Then compile the file into a pdf document:

$ pdflatex image.tex
share|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
add comment

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

share|improve this answer
add comment

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).

share|improve this answer
1  
Here the syntax for pdftk: pdftk img1.pdf img2.pdf output all.pdf –  jofel Mar 16 '12 at 23:42
add comment

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

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

share|improve this answer
add comment
  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.

share|improve this answer
add comment

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.