Skip to content

Commit

Permalink
Add helpful messages if missing requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
jonchang committed Apr 10, 2024
1 parent 34a349b commit e399e8c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions OCR/image-alignment/go.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
#!/bin/bash
# download pertussis PDFs from:
# https://drive.google.com/drive/folders/1vG-XwFiOoRunx9eXCmd41WpAI5NCizeM

set -eu

HELPSTR="
Download these files:
0_Pertussis.fillable_Redacted.pdf
1_Pertussis.scanned paper_Redacted.pdf
from this Google Drive folder:
https://drive.google.com/drive/folders/1vG-XwFiOoRunx9eXCmd41WpAI5NCizeM
"

if [[ ! -f "0_Pertussis.fillable_Redacted.pdf" && ! -f "1_Pertussis.scanned paper_Redacted.pdf" ]]; then
echo "$HELPSTR"
exit 1
fi

if [[ ! -x $(which convert) ]]; then
echo "This script requires ImageMagick and the \`convert\` binary to be available."
exit 1
fi

# Extract the first page of each PDF and rasterize it as a PNG
convert -density 300 "0_Pertussis.fillable_Redacted.pdf[0]" -background white -alpha remove pertussis-filled.png
convert -density 300 "1_Pertussis.scanned paper_Redacted.pdf[0]" -background white -alpha remove pertussis-scanned.png
Expand Down

0 comments on commit e399e8c

Please sign in to comment.