From e58b0ded9d8a625cc6ae5148fd8bde74fce56bd7 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Wed, 15 Nov 2017 18:51:45 +0100 Subject: [PATCH] script to convert 1st page of PDF to jpeg --- README | 8 ++++++++ pdf_cover.sh | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 pdf_cover.sh diff --git a/README b/README index 2e82421..a7b4f29 100644 --- a/README +++ b/README @@ -31,6 +31,14 @@ python wiki-download.py --help python imposition.py --dir imgs/ --size a3 --order random +### pdf_cover.sh +Converts first page of PDFs to a jpeg with the ending _cover.jpeg + +Usage: +./pdf_cover.sh imgs-dir-name + +Software dependencies: +gs (ghostscript) ### imgs2pdf.sh diff --git a/pdf_cover.sh b/pdf_cover.sh new file mode 100644 index 0000000..a9124dc --- /dev/null +++ b/pdf_cover.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Script converts first page of PDFs to a jpeg with the ending _cover.jpeg +# Software dependencies: gs +# Usage: ./pdf_cover.sh imgs-dir-name + +DIR="" +echo ${#1} + +if [ ${#1} -gt 0 ] # check arguments given +then + DIR=$1 + echo "PDF from $DIR directory: cover converted to png" + + for f in $DIR/*.pdf # convert imgs to tmp pdfs + do + COVER=$DIR/`basename "$f" .pdf`_cover.jpeg + echo $COVER + gs -q -dNOPAUSE -dSAFER -dBATCH -sDEVICE=jpeg -r300x300 -sOutputFile="$COVER" -dLastPage=1 "$f" +# convert "$f"[0] "$COVER" + done +# pdftk $DIR*.pdf cat output $FILENAME # concatonate single pdf into 1 pdf +else + echo "You forgot to provide the PDFs directory as first argument" +fi