script to convert 1st page of PDF to jpeg

master
Castro0o 7 years ago
parent f55323f854
commit e58b0ded9d

@ -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

@ -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
Loading…
Cancel
Save