Commit 61559508 authored by Christian Rohlfing's avatar Christian Rohlfing

- bugfix in watermark

parent b0bbe729
......@@ -11,12 +11,13 @@ set -o pipefail # don't hide errors within pipes
# Default values
infolder="./pdfs/sorted"
outfolder="./pdfs/watermarked"
tmpfolder=$(mktemp -d)
tmpfolder="/tmp"
cores=$(nproc)
dpi="250"
quality="25"
v=n
author="IENT RWTH Aachen, 2020"
split=n
#{{{ Input parameter handling
# Copied from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
......@@ -28,7 +29,7 @@ Options:
-h, --help show this help text
-i, --in input folder with PDFs. Default: ${infolder}
-o, --out output folder. Default: ${outfolder}
-t, --tmp temporary folder
-t, --tmp parent of temporary folder. Default ${tmpfolder}
-j, --cores number of cores for parallel processing. Default: ${cores}
-d, --dpi dpi parameter for conversion from pdf to images. Default: ${dpi}
-q, --quality quality parameter for jpeg. Default: ${quality}
......@@ -118,7 +119,6 @@ while true; do
esac
done
# Check folders
for f in \
"$infolder" \
......@@ -132,6 +132,7 @@ do
done
#}}}
# List all PDFs
echo
echo "Available PDFs"
......@@ -150,6 +151,10 @@ doit () {
quality=$4
split=$5
lauthor=$6
pretmpfolder=$7
# Create temporary folder per job
tmpfolder="$(mktemp -d -p ${pretmpfolder})"
# Get matriculation number from file
inpdf=$(basename "${longinpdf%.*}") # file name without folder and extension
......@@ -286,10 +291,10 @@ doit () {
if [[ "${cores}" -gt "1" ]]; then
echo "Parallel execution with ${cores} cores from now on."
export -f doit
parallel -j "${cores}" doit ::: "${infolder}"/*.pdf ::: "${outfolder}" ::: "${dpi}" ::: "${quality}" ::: "${split}" ::: "${author}"
parallel -j "${cores}" doit ::: "${infolder}"/*.pdf ::: "${outfolder}" ::: "${dpi}" ::: "${quality}" ::: "${split}" ::: "${author}" ::: "${tmpfolder}"
else
for longinpdf in "${infolder}"/*.pdf
do
doit "${longinpdf}" "${outfolder}" "${dpi}" "${quality}" "${split}" "${author}"
doit "${longinpdf}" "${outfolder}" "${dpi}" "${quality}" "${split}" "${author}" "${tmpfolder}"
done # end of PDF loop
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment