From 3cb530f077823e28a7675d6a42e041b79036bf04 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Wed, 21 Apr 2021 19:49:30 +0200 Subject: [PATCH] bin: add script to sign pdf and shrink images --- .local/bin/scripts/shrinkimg | 10 ++++++++++ .local/bin/scripts/sign | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 .local/bin/scripts/shrinkimg create mode 100755 .local/bin/scripts/sign diff --git a/.local/bin/scripts/shrinkimg b/.local/bin/scripts/shrinkimg new file mode 100755 index 0000000..439bac4 --- /dev/null +++ b/.local/bin/scripts/shrinkimg @@ -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" + diff --git a/.local/bin/scripts/sign b/.local/bin/scripts/sign new file mode 100755 index 0000000..da5030d --- /dev/null +++ b/.local/bin/scripts/sign @@ -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"