This repo collects convenient scripts.
- graypdf. Convert PDF to grayscale.
- mergepdf. Merge a sequence of PDF files.
| #!/bin/bash | |
| # Convert PDF to grayscale: http://superuser.com/q/104656/149756 | |
| if [ $# -ne 2 ]; then | |
| echo $0: usage: pdf2gray input output | |
| exit 1 | |
| fi | |
| input=$1 | |
| output=$2 | |
| gs \ | |
| -sOutputFile=$output \ | |
| -sDEVICE=pdfwrite \ | |
| -sColorConversionStrategy=Gray \ | |
| -dProcessColorModel=/DeviceGray \ | |
| -dCompatibilityLevel=1.4 \ | |
| -dNOPAUSE \ | |
| -dBATCH \ | |
| $input |
| #!/bin/bash | |
| hash gs 2>/dev/null || { | |
| echo >&2 "I require gs but it's not installed." | |
| return | |
| } | |
| if [ $# -lt 3 ]; then | |
| echo >&2 "Require at least two inputs and one output file." | |
| return | |
| fi | |
| src=${@:1:$(($#-1))} | |
| des=${@:$#} | |
| gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite \ | |
| -sOutputFile=$des $src |
This repo collects convenient scripts.