add option to not post-process pictures
This commit is contained in:
parent
dc4c5498b2
commit
822b984678
33
photos2pdf
33
photos2pdf
@ -48,7 +48,7 @@ sigmoidal_contrast="45,50%"
|
||||
posterize=6
|
||||
|
||||
# Keep intermediate images after processing
|
||||
keep_tmpfiles=true
|
||||
keep_tmpfiles=false
|
||||
|
||||
# Paper size of all pages
|
||||
paper="a4paper"
|
||||
@ -111,8 +111,14 @@ Arguments
|
||||
---------
|
||||
* `DIR`: Directory containing the original photos.
|
||||
|
||||
Options
|
||||
-------
|
||||
General Options
|
||||
---------------
|
||||
* `--help`: Print this message and exit.
|
||||
* `--direct`: Do not perform post-processing; use
|
||||
original image.
|
||||
|
||||
Post-Processing Options
|
||||
-----------------------
|
||||
* `--simplify INT`: Before morphology analysis, reduce
|
||||
image dimensions by this factor
|
||||
(default: 2).
|
||||
@ -148,6 +154,7 @@ EOF
|
||||
##
|
||||
# Arguments
|
||||
|
||||
direct=false
|
||||
i=1
|
||||
options_done=false
|
||||
|
||||
@ -160,6 +167,11 @@ while [[ $i -le $# ]] ; do
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
--direct)
|
||||
direct=true
|
||||
i=$((i+1))
|
||||
continue
|
||||
;;
|
||||
--simplify| \
|
||||
--morphology| \
|
||||
--morphology-shape| \
|
||||
@ -262,6 +274,14 @@ if [[ $rv -ne 0 ]] ; then
|
||||
error "One or more errors during input file naming; aborted." "$rv"
|
||||
fi
|
||||
|
||||
if "$direct" ; then
|
||||
for jpg in "$indir/"*.jpg ; do
|
||||
base=$(basename "$jpg" .jpg)
|
||||
out="$outdir/$base.png"
|
||||
info "Resizing $jpg to $out ..."
|
||||
convert -resize 1024 -dither Riemersma -colors 24 "$jpg" "$out"
|
||||
done
|
||||
else
|
||||
for jpg in "$indir/"*.jpg ; do
|
||||
base=$(basename "$jpg" .jpg)
|
||||
tmp1="$tmpdir/$base.tmp1.png"
|
||||
@ -373,6 +393,7 @@ for jpg in "$indir/"*.jpg ; do
|
||||
continue
|
||||
fi
|
||||
done
|
||||
fi # !direct
|
||||
|
||||
if [[ $rv -ne 0 ]] ; then
|
||||
error "One or more errors during image conversion; aborted." "$rv"
|
||||
@ -437,13 +458,15 @@ while read -r pdf ; do
|
||||
input+=("$pdf")
|
||||
done < <(ls -- "$tmpdir/"*.backdropped.pdf)
|
||||
|
||||
result_pdf=$(readlink -f "$result_filename")
|
||||
|
||||
if ! \
|
||||
qpdf \
|
||||
--empty \
|
||||
--pages "${input[@]}" \
|
||||
-- "$result_filename"
|
||||
-- "$result_pdf"
|
||||
then
|
||||
warning "Could not concatenate \"$result_filename\"."
|
||||
warning "Could not concatenate \"$result_pdf\"."
|
||||
rv=1
|
||||
elif ! "$keep_tmpfiles" ; then
|
||||
if ! rm -f -- "$tmp_base" ; then
|
||||
|
Loading…
Reference in New Issue
Block a user