#!/bin/bash NC='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' msg_info() { echo -e "${GREEN}$1${NC}" } msg_warn() { echo -e "${YELLOW}$1${NC}" } msg_error() { echo -e "${RED}$1${NC}" } print_help() { echo echo "scan2pdf - turn document pictures into searchable PDFs" echo echo " scan2pdf uses unpaper to clean the input image and" echo " tesseract to extract the text and bundle everything in a" echo " single PDF. imagemagick is used to prepare the input for" echo " unpaper, and sxiv to selectively repeat the cleaning" echo " process, when needed. Results may vary, depending on the" echo " quality of the input image and the options used with" echo " unpaper." echo echo "USAGE:" echo " unpaper [OPTION ...] FILE [...]" echo echo "OPTIONs are:" echo " -o | --output " echo " provide a name for the output file (without extension)" echo " -h | --help" echo " print this help" echo } batch_convert() { echo echo "Batch converting scans to PNM." for IMG in "${INPUT[@]}" do IMG_BASE=`basename $IMG` IMG_BASE_PNM="${IMG_BASE%.*}.pnm" echo "Converting $IMG -> $TEMP/$IMG_BASE_PNM" convert "$IMG" "$TEMP/$IMG_BASE_PNM" TO_PROCESS+=( "$TEMP/$IMG_BASE_PNM" ) done } batch_unpaper() { echo echo "Batch unpaper scans." # Prompt user to get additional unpaper options. It is possible to # access the man page as well. UNPAPER_MORE_OPTIONS=() echo "Using the following options: ${UNPAPER_OPTIONS[@]}" echo "Specify additional options (quit|man|