#!/bin/bash rm -f book.pdf cnt=0 f_fls="" for file in $( ls *.jpg | sort -n ); do convert $file tmp.tiff if tiff2bw tmp.tiff tmp; then tiffdither -c g4 tmp ${cnt}.tiff; else cp tmp.tiff ${cnt}.tiff; fi # convert -rotate 180 $file ${cnt}.tiff f_fls="${f_fls} ${cnt}.tiff" let cnt=cnt+1 done # Make result tiff file tiffcp ${f_fls} book.tiff # Make pdf file tiff2pdf book.tiff -o book.pdf