commit 73003276e489348e9a1caf858a420d58db7cb987 Author: Castro0o Date: Wed Oct 18 16:45:27 2017 +0200 first script from utils imgs2pdf diff --git a/README b/README new file mode 100644 index 0000000..0bcc95f --- /dev/null +++ b/README @@ -0,0 +1,14 @@ +# Utility Scripts for scanning documents + + +## Software dependencies: +pdftk, imagemagick + +## Scripts +### imgs2pdf.sh +Converts a directory of images onto a single PDF + +Usage: ./imgs2pdf.sh imgs-dir-name pdf-filename +If no pdf-filename is provided, output.pdf will the default file name + + diff --git a/imgs2pdf.sh b/imgs2pdf.sh new file mode 100755 index 0000000..2d23e31 --- /dev/null +++ b/imgs2pdf.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# Script to convert directory of images onto a single PDF +# Software dependencies: pdftk, imagemagick +# Usage: ./imgs2pdf.sh imgs-dir-name pdf-filename +# if no pdf-filename is provided, output.pdf will the default file name + +DIR="" +FILENAME="" +echo ${#1} + +if [ ${#1} -gt 0 ] # check arguments given +then + DIR=$1 + echo "Images from $DIR directory are being converted onto PDF" + + if [ ${#2} -gt 0 ] + then + FILENAME=$2 + + else + FILENAME=output.pdf + fi + echo "under the filename: $FILENAME" + PROCESS=true +else + echo "You forgot to provide the images directory as the first argument" + PROCESS=false +fi + +if $PROCESS true; +then + echo "processing..." + for IMG in $DIR* # convert imgs to tmp pdfs + do PDF=${IMG%.*}.pdf + convert -density 200 $IMG $PDF + done + pdftk $DIR*.pdf cat output $FILENAME # concatonate single pdf into 1 pdf + +fi + + +