Bash script for enhancing scanned/book PDFs. Renders pages to grayscale, applies gamma and contrast, optionally converts to 1-bit (threshold/adaptive), then merges into a compact printable PDF. Parallel and memory-aware.
Ghostscript, ImageMagick, img2pdf, GNU parallel, poppler
sudo apt install ghostscript imagemagick img2pdf parallel poppler-utilssudo dnf install ghostscript ImageMagick img2pdf parallel poppler-utilssudo pacman -S ghostscript imagemagick img2pdf parallel poppler./pdf2scan.sh [options] input.pdf output.pdfOptions:
-d, --dpirender DPI (default 100)-g, --gammagamma correction-c, --contrastbrightness/contrast-t, --thresholdconvert to 1-bit (e.g. 50%)-a, --adaptiveadaptive 1-bit-q, --qualityJPEG quality (default 60)-v, --verboseverbose logs-h, --helpshow help
