diff options
author | Aaron LI <aly@aaronly.me> | 2017-11-03 18:31:03 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-11-03 18:31:03 +0800 |
commit | bc87a53a283d7dec8c52cccf4689fb2d9765a277 (patch) | |
tree | 8a859562087f2999f901cce4eced0827c4a2b944 /cli/jpg2pdf.sh | |
parent | b50463d171ade46f549c5331e8ad317b410ac0f2 (diff) | |
download | atoolbox-bc87a53a283d7dec8c52cccf4689fb2d9765a277.tar.bz2 |
Move several scripts from unix/ to cli/
Diffstat (limited to 'cli/jpg2pdf.sh')
-rwxr-xr-x | cli/jpg2pdf.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cli/jpg2pdf.sh b/cli/jpg2pdf.sh new file mode 100755 index 0000000..ac992af --- /dev/null +++ b/cli/jpg2pdf.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# +############################################################################# +# +# Shellscript to convert a set of JPEG files to a multipage PDF. +# +# Requirements: (1) Ghostscript needs to be installed on the local system. +# (2) ImageMagick needs to be installed on the local system. +# +# Usage: jpegs2pdf.sh output.pdf file1.jpeg [file2.jpeg [file2.jpeg [...]]] +# +# Copyright (c) 2007, <pipitas@gmail.com> +# Use, distribute and modify without any restrictions. +# +# Versions: +# v1.0.0, Jul 12 2007: initial version +# v1.0.1, Jan 07 2011: set viewJPEG.ps path (self-compiled GS 9.02) +# +############################################################################# + +outfile=$1 +shift + +param="" +for i in "$@" ; do + dimension=$(identify -format "%[fx:(w)] %[fx:(h)]" "${i}") + param="${param} <</PageSize [${dimension}]>> setpagedevice (${i}) viewJPEG showpage" +done + +gs \ + -sDEVICE=pdfwrite \ + -dPDFSETTINGS=/prepress \ + -o "$outfile" \ + viewjpeg.ps \ + -c "${param}" + |