Skip to content

Instantly share code, notes, and snippets.

@jacksenechal
Last active March 26, 2025 21:12
Show Gist options
  • 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 - boolean, keep original file
# $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"
@bobgomez
Copy link

Thanks for the script. It is what I was looking for.
FYI, I found that the second parameter from simple-scan (the 'unknown boolean') seems to be the flag "keep original file' from the config. I guess with that the script can deal with naming the output file to ocrmypdf.

@jameshightower
Copy link

Thank you!

@plenaerts
Copy link

Thanks!

Simplescan should document this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment