How to create pdf from images in Terminal
Now and then I find myself in the situation where I need to create a pdf from some images. I often resort to Preview, but it can be quite cumbersome at times. There is however an easier and faster option, but it requires that you use the Terminal.
Images to pdf step by step
- First you need Homebrew, which is basically the app store for Terminal. If you don’t have it installed open you can follow the setup at brew.sh.
- Once done close your terminal and open it up again (to make sure that Homebrew works)
- Then type in
brew install imagemagick. This installs imagemagic which is the program that will help us create the pdf-files.
- When finished close and open up your Terminal again.
- Next step is to find the folder where we have the source images we want converted. The easiest way to do that is to find the folder in Finder. Then in your Terminal type in
cdand then drag your folder into your Terminal window. Now it will read
cd Downloads/imagesor something similar. Then press enter. Now we have navigated to a new folder in Terminal!
- Type in
convert *.jpg output.pdfwhich means use imagemagick to convert all jpg-files in this folder and combine them to a pdf called output.pdf. You can adjust this if you f.ex. have png-files, or create your own name on the pdf:
convert *.png myAwesomeFile.pdf.
- You now have a pdf-file with all your images combined!
If you want the file in a specific order I recommend naming your files with numbers. F.ex: 1-onboarding.png, 2-signing.png. You can also type your files directly out like
convert onboarding.png signing.png output.pdf
If the resulting pdf is too big in size you can try:
convert -quality 60 *.jpg output.pdf
To convert images to pdf:
brew install imagemagick
convert *.jpg output.pdf