]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
add ocr case multi thread or multi file
authorBastian Dehn <hhaalo@arcor.de>
Mon, 24 Nov 2025 18:30:31 +0000 (19:30 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 24 Nov 2025 18:44:25 +0000 (19:44 +0100)
src/scanbasic.sh

index ff20f8008a48519c7a325a08ab6778065226f79a..4cf9e44dc7f2521fd3f896c701ef1951fec803e6 100644 (file)
@@ -59,6 +59,7 @@ optimize()
 addocr()
 {
        local input="$1"
+       local multi="$2"
        local output="$input-out"
 
        [ -n "$input" ] \
@@ -66,9 +67,15 @@ addocr()
                || return $?
 
        echo "ℹ️  INFO: adding ocr on file $input"
-       ocrmypdf --quiet --jobs 1 --language deu $input $output \
-               || errlog "could not add ocr on $input" \
-               || return $?
+       if [ "$multi" == "true" ]; then
+               ocrmypdf --quiet --jobs 1 --language deu $input $output \
+                       || errlog "could not add ocr on $input" \
+                       || return $?
+       else
+               ocrmypdf --quiet --jobs $(nproc) --language deu $input $output \
+                       || errlog "could not add ocr on $input" \
+                       || return $?
+       fi
 
        [ ! -f $output ] && return 0
 
@@ -146,7 +153,7 @@ createpdf()
 
 detectsplit()
 {
-       local pdf=$1
+       local pdf="$1"
        local trenn=
 
        [ -n "$pdf" ] \
@@ -178,7 +185,7 @@ createmultipdfs()
        export -f optimize
        find . -name "scanned-$$-*.pdf" \
                | sort \
-               | parallel --keep-order addocr {}
+               | parallel --keep-order addocr {} true
 
        local startcount=1
        local endcount=1