Skip to content

Instantly share code, notes, and snippets.

@jacksenechal
Last active March 23, 2024 20:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacksenechal/53dbf568438b212e7886b168ea4221c3 to your computer and use it in GitHub Desktop.
Save jacksenechal/53dbf568438b212e7886b168ea4221c3 to your computer and use it in GitHub Desktop.
Gnome simple-scan post processing script to run OCR with ocrmypdf
#!/bin/bash
# ocr-script.sh
#
# Useage: set this file as the post-processing script in the simple-scan preferences. No extra arguments needed.
#
# Requirements:
# - simple-scan
# - ocrmypdf
#
# For reference, at the time of writing the arguments from simple-scan are:
# $1 - the mime type, eg application/pdf
# $2 - unknown boolean
# $3 - the filename
# $4..N - postprocessing script arguments entered in preferences
filename=$3
/usr/bin/ocrmypdf --deskew --clean --force-ocr "$filename" "$filename" &> /tmp/ocr.log
if [ $? -ne 0 ]; then
notify-send "OCR failed. See /tmp/ocr.log"
exit 1
fi
notify-send "OCR complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment