Recently Written · git

sh

Small shell and Python scripts

git clone https://github.com/equwal/sh

Log | Files | Refs


jpegify (439 bytes)

1 #!/bin/sh
2 # Shrink a PDF by re-rendering every page as a JPEG (via jpegify-aux).
3 # Usage: jpegify FILE.pdf   (writes ./FILE.pdf-jpeg.pdf)
4 set -e
5 TEMP="$(mktemp -d)"
6 trap 'rm -r "$TEMP"' EXIT
7 OUT="$PWD/$(basename "$1")-jpeg.pdf"
8 pdfseparate "$1" "$TEMP"/%d.pdf
9 
10 cd "$TEMP"
11 for p in *.pdf; do jpegify-aux "$p"; done
12 # shellcheck disable=SC2046 # page files are N.pdf-jpeg.pdf: no spaces
13 pdfunite $(printf '%s\n' *-jpeg.pdf | sort -n) "$OUT"