There are a number of ways you can go about the process of converting image files into PDFs, most simply by opening a given image and printing it. You can select “Print to file” instead of a printer device, PDF format is the default for this type of output. But say you have a folder full of images and you want to make one big PDF of them. Here’s how you can do that:
1 2 3 4 5 6 7 | cd FOLDER_WITH_IMAGES FILES=$(ls *jpg) mkdir temp && cd temp for file in $FILES; do BASE=$(echo $file | sed 's/.jpg//g'); convert ../$BASE.jpg $BASE.pdf; done && pdftk *pdf cat output ../FINAL_NAME.pdf && cd .. rm -rf temp |
This loops through all the .jpg images in the directory and converts them to a PDF file of the same name. Once that is done they are all combined into FINAL_NAME.pdf by pdftk, a handy PDF utility. The temp dir business is there to make the temp PDF file removal easier.
Possibly Related (no promises):
Related posts brought to you by Yet Another Related Posts Plugin.








It worked very very well!
I had problems with the “convert” (from imagemagick) because it makes my computer run out of memory when I want to convert a lot of image files into one pdf. This seems to solve the problem. I just wich I could understand all the those BASE=$ commands. lol
@Montebelo I’m glad it worked for you! Actually that command probably looks trickier than it is. The for loop iterates over each item in the FILES variable (i.e. all the image files we want to convert). For each item BASE is set to the image filename with the extension (“.jpg”) stripped. This is so we can title our output the same as the original. In the convert step, we use BASE to specify what image to convert and also what to call the resultant PDF. Hope that helps!