bin: add script to sign pdf and shrink images

This commit is contained in:
xerus2000 2021-04-21 19:49:30 +02:00
parent c647431f4e
commit 3cb530f077
2 changed files with 25 additions and 0 deletions

10
.local/bin/scripts/shrinkimg Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
while true
do case $1 in
(-o) out=$2; shift 2;;
(-q) quality=$2; shift 2;;
(*) break;;
esac
done
magick '$@' -strip -interlace Plane -define jpeg:dct-method=float -sampling-factor 4:2:0 -gaussian-blur 0.05 -quality "${quality:-85}" "$out"

15
.local/bin/scripts/sign Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
signature=$(pass tools/signature)
# TODO make filenames unique and don't rerun unneccessarily
tmp_base=/tmp/sign
mkdir -p $tmp_base
tmp_signed=$tmp_base/$1_last-signature.pdf
tmp_reversed=$tmp_base/$1_reverse.pdf
sig=$tmp_base/signature_offset.pdf
result="${1%.pdf}_signed.pdf"
pdfjam "$signature" --outfile "$sig" --offset "${2:-0}pt ${3:-0}pt" --papersize "{595pt, 842pt}" --noautoscale true --scale "${4:-1}"
pdfjam "$1" last "$sig" --outfile "$tmp_signed" --delta "0 -842pt" --nup "1x2" --fitpaper true
pdfjam "$1" last-1 --outfile "$tmp_reversed"
pdfjam "$tmp_reversed" last-2 "$tmp_signed" --outfile "$result"
xdg-open "$result"