How can I convert about 100 PNGs to one PDF on a Mac? I'm open to using the command line if it helps.
I have tried using iPhoto, but it quits, not sure why. Saving from Preview doesn't quite do what I want. Thoughts?
16 Answers
If you have Leopard (10.5 or later) or Lion the easiest way is to use Preview. Just do the following:
- Open the first image in Preview
- Show the the sidebar (Shift-Command-D)
- Drag any additional images to the sidebar
- Go to File > Print (Command P)
- In the PDF dropdown list select Save as PDF
That's it! You should now have a PDF containing all your images.
If that doesn't work for you, you should look at any third-party solutions such as Adobe Acrobat Pro which has a combine feature or PDFLab.
7I prefer using command line tools such as ImageMagick for this type of work. You can install IM with Homebrew:
brew install imagemagickAfterwards you can do
convert *.jpg output.pdfand if the resulting PDF is a bit too big you can try:
convert -quality 60 *.jpg output.pdfOf course ImageMagick also works on other Unix systems, and even on cygwin.
(If you want a specific order you can also write out the .jpg filenames one by one. Or use * and rename the .jpgs in alphabetical order.)
My method is similar to Marcus's, but works a little better for me when the images are all different sizes and you don't want the PDF to just be all 8.5x11 but to keep each page the size of the original image.
- Open the first image in Preview
- Show thumbnails (Command-option-2)
- Drag any additional images to the sidebar
After this we diverge:
- Select all image thumbnails in the sidebar (select one by clicking, then Command-A)
- File > Export Selected Images...
- Select or create a folder to hold your temporary images, set Format to PDF, and click Choose
- Close all original images
- Open the LAST exported PDF in Preview (this will become the last page)
- Drag all the other exported PDFs to the sidebar and drop ON TOP of the thumbnail for the exported PDF you just opened
- This should create a multipage PDF with the images in the same order they were in the Finder. Rename it so you can find it easily, save and you're done.
On more current versions of OSX, you may be better off using the native command line tool sips - see the answered Stack Overflow question 6349984, which converts from pdf to png. It should be far easier to script sips (which has been available since ~2009) than click multiple times within Preview.
Essentially,
sips -s format pdf input-png-file-path --out output-pdf-file-path I highly recommend the Python CLI program img2pdf for lossless conversion:
Example usage:
img2pdf img1.png img2.jpg -o out.pdf 2 A much simpler way is to use the rather overlooked app Automator, that you find in the Applications folder.
This link shows exactly how: Use Automator to combine your research photos into one PDF
1