ImageMagick is excellent for batch-processing scanned book pages. Here's a practical workflow to improve color, brightness, and contrast while preserving readability.
🔧 1. Basic Adjustments
Use convert (or magick in newer versions) with these key options:
Brightness / Contrast
bash Copy code
magick input.jpg -brightness-contrast 10x20 output.jpg
10: increases brightness by 10%
20: increases contrast by 20%
Gamma (mid-tone adjustment)
bash Copy code
magick input.jpg -gamma 1.2 output.jpg
1.2: lightens mid-tones slightly (use <1 to darken)
Levels (black/white point stretch)
bash Copy code
magick input.jpg -level 15%,85% output.jpg
Stretches the histogram: 15% becomes black, 85% becomes white. Adjust based on your scans.
🧹 2. Clean Background & Text
Normalize (auto-contrast)
bash Copy code
magick input.jpg -normalize output.jpg
Stretches the histogram to full range.
Auto-level (more aggressive)
bash Copy code
magick input.jpg -auto-level output.jpg
Like -normalize, but per-channel (can help with color casts).
Desaturate (for grayscale-ish scans)
bash Copy code
magick input.jpg -colorspace Gray output.jpg
Or use -monochrome for pure black-and-white (1-bit), but this can lose detail.
🧪 3. Batch Processing Script
Save as process.sh:
bash Copy code
#!/bin/bash
mkdir -p processed
for img in *.jpg; do
magick "$img" \
-colorspace Gray \
-normalize \
-brightness-contrast 5x10 \
-sharpen 0x1 \
"processed/$img"
done
-sharpen 0x1: subtle sharpening to improve text clarity.
Adjust values per your scans.
🧰 4. Optional: Remove Color Cast
If scans have a yellowish tint:
bash Copy code
magick input.jpg -white-balance output.jpg
Or manually adjust white balance:
bash Copy code
magick input.jpg -channel RGB -level 10%,90% +channel output.jpg
✅ Tips
Test on one image first before batching.
Use -quality 92 for JPG output to avoid compression artifacts.
Preserve originals – always output to a new folder.
📌 Example Final Command
bash Copy code
magick scan.jpg -colorspace Gray -normalize -level 10%,90% -brightness-contrast 5x10 -sharpen 0x1 -quality 92 clean_scan.jpg
Let me know if your scans are skewed or have page curl – I can help with deskewing and cropping too.