From 5322969e673f283e3d9413d925e9b2abcacde2af Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 29 Dec 2017 17:22:21 +0800 Subject: Rename shrinkpdf.sh and mergepdf.sh --- cli/mergepdf.sh | 23 ---------------------- cli/pdf-compress.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ cli/pdf-merge.sh | 23 ++++++++++++++++++++++ cli/shrinkpdf.sh | 56 ----------------------------------------------------- 4 files changed, 79 insertions(+), 79 deletions(-) delete mode 100755 cli/mergepdf.sh create mode 100755 cli/pdf-compress.sh create mode 100755 cli/pdf-merge.sh delete mode 100755 cli/shrinkpdf.sh diff --git a/cli/mergepdf.sh b/cli/mergepdf.sh deleted file mode 100755 index aef72db..0000000 --- a/cli/mergepdf.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# -# Merge multiple PDFs with pdftk. -# -# Ref: -# Merging Multiple PDFs under GNU/Linux -# https://blog.dbrgn.ch/2013/8/14/merge-multiple-pdfs/ -# -# Weitian LI -# 2015/01/23 -# - -if [ $# -lt 2 ]; then - printf "Usage: `basename $0` out.pdf in1.pdf ...\n" - exit 1 -fi - -outpdf="$1" -shift - -echo "Input files: $@" -pdftk "$@" cat output "${outpdf}" - diff --git a/cli/pdf-compress.sh b/cli/pdf-compress.sh new file mode 100755 index 0000000..9f68c4c --- /dev/null +++ b/cli/pdf-compress.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# +# Shrink the size of PDF files by adjust its quality using `gs` (GhostScript). +# +# Aaron LI +# 2013/09/18 +# + +case "$1" in + -[hH]*|--[hH]*) + printf "usage:\n" + printf " `basename $0` in= out= quality= imgdpi=\n" + exit 1 + ;; +esac + +getopt_keyval() { + until [ -z "$1" ] + do + key=${1%%=*} # extract key + val=${1#*=} # extract value + keyval="${key}=\"${val}\"" + echo "## getopt: eval '${keyval}'" + eval ${keyval} + shift # shift, process next one + done +} +getopt_keyval "$@" + +if [ -z "${in}" ] || [ -z "${out}" ]; then + printf "Error: 'in' or 'out' not specified\n" + exit 2 +fi +quality=${quality:-ebook} +imgdpi=${imgdpi:-120} + +printf "# in: ${in} +# out: ${out} +# quality: ${quality} +# imgdpi: ${imgdpi}\n" + +gs -dNOPAUSE -dBATCH -dSAFER \ + -sDEVICE=pdfwrite \ + -dCompatibilityLevel=1.4 \ + -dPDFSETTINGS="/${quality}" \ + -dEmbedAllFonts=true \ + -dSubsetFonts=true \ + -dColorImageDownsampleType=/Bicubic \ + -dColorImageResolution=${imgdpi} \ + -dGrayImageDownsampleType=/Bicubic \ + -dGrayImageResolution=${imgdpi} \ + -dMonoImageDownsampleType=/Bicubic \ + -dMonoImageResolution=${imgdpi} \ + -sOutputFile=${out} \ + ${in} + diff --git a/cli/pdf-merge.sh b/cli/pdf-merge.sh new file mode 100755 index 0000000..aef72db --- /dev/null +++ b/cli/pdf-merge.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Merge multiple PDFs with pdftk. +# +# Ref: +# Merging Multiple PDFs under GNU/Linux +# https://blog.dbrgn.ch/2013/8/14/merge-multiple-pdfs/ +# +# Weitian LI +# 2015/01/23 +# + +if [ $# -lt 2 ]; then + printf "Usage: `basename $0` out.pdf in1.pdf ...\n" + exit 1 +fi + +outpdf="$1" +shift + +echo "Input files: $@" +pdftk "$@" cat output "${outpdf}" + diff --git a/cli/shrinkpdf.sh b/cli/shrinkpdf.sh deleted file mode 100755 index 9f68c4c..0000000 --- a/cli/shrinkpdf.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# -# Shrink the size of PDF files by adjust its quality using `gs` (GhostScript). -# -# Aaron LI -# 2013/09/18 -# - -case "$1" in - -[hH]*|--[hH]*) - printf "usage:\n" - printf " `basename $0` in= out= quality= imgdpi=\n" - exit 1 - ;; -esac - -getopt_keyval() { - until [ -z "$1" ] - do - key=${1%%=*} # extract key - val=${1#*=} # extract value - keyval="${key}=\"${val}\"" - echo "## getopt: eval '${keyval}'" - eval ${keyval} - shift # shift, process next one - done -} -getopt_keyval "$@" - -if [ -z "${in}" ] || [ -z "${out}" ]; then - printf "Error: 'in' or 'out' not specified\n" - exit 2 -fi -quality=${quality:-ebook} -imgdpi=${imgdpi:-120} - -printf "# in: ${in} -# out: ${out} -# quality: ${quality} -# imgdpi: ${imgdpi}\n" - -gs -dNOPAUSE -dBATCH -dSAFER \ - -sDEVICE=pdfwrite \ - -dCompatibilityLevel=1.4 \ - -dPDFSETTINGS="/${quality}" \ - -dEmbedAllFonts=true \ - -dSubsetFonts=true \ - -dColorImageDownsampleType=/Bicubic \ - -dColorImageResolution=${imgdpi} \ - -dGrayImageDownsampleType=/Bicubic \ - -dGrayImageResolution=${imgdpi} \ - -dMonoImageDownsampleType=/Bicubic \ - -dMonoImageResolution=${imgdpi} \ - -sOutputFile=${out} \ - ${in} - -- cgit v1.2.2