From e399e8c4b8df675f0a082e0cd18cf81310629b8c Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Wed, 10 Apr 2024 09:45:54 -0700 Subject: [PATCH] Add helpful messages if missing requirements --- OCR/image-alignment/go.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/OCR/image-alignment/go.sh b/OCR/image-alignment/go.sh index eac60c56..3cf9f0f5 100755 --- a/OCR/image-alignment/go.sh +++ b/OCR/image-alignment/go.sh @@ -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