commit 4397d87106ee20511545c5438acfbc6ed8e9a459 parent a9d495a3510c7d6eb81735cb8d76f3efd5386ccb Author: Alex Balgavy <a.balgavy@gmail.com> Date: Thu, 9 Apr 2020 16:12:27 +0200 pdfcompress to compress pdfs with ghostscript Former-commit-id: cd5306863ddae409113c9419fd2da5229d104848 Diffstat:
A | scripts/pdfcompress | | | 16 | ++++++++++++++++ |
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git a/scripts/pdfcompress b/scripts/pdfcompress @@ -0,0 +1,16 @@ +#!/bin/sh +if ! command -v gs 1>/dev/null 2>&1; then + echo "ghostscript not installed." >&2 + exit 1 +fi +[ $# -eq 2 ] || { echo "Arguments: infile, outfile"; exit 1; } + +while + _i=0 _quality='' quality='' + for _name in "/screen (lowest)" "/ebook" "/printer" "/prepress" "/default"; do echo "$((_i+=1))) $_name"; done + printf '$# '; read -r _quality +do + case $_quality in 1) quality="/screen (lowest)";; 2) quality="/ebook";; 3) quality="/printer";; 4) quality="/prepress";; 5) quality="/default";; *) continue;; esac + gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS="$quality" -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$2" "$1" + break +done