Last active
March 26, 2025 21:12
-
-
Save jacksenechal/53dbf568438b212e7886b168ea4221c3 to your computer and use it in GitHub Desktop.
Gnome simple-scan post processing script to run OCR with ocrmypdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Thank you!
Thanks!
Simplescan should document this!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.