]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
change all commands check availibility
authorBastian Dehn <hhaalo@arcor.de>
Sun, 6 Jul 2025 09:28:20 +0000 (11:28 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 6 Jul 2025 09:28:20 +0000 (11:28 +0200)
src/scanbasic.sh

index b7d7692210db593945958f87cf96171882052376..3352d962c79761dec1d31c94887b115b7c1cf97f 100644 (file)
@@ -8,17 +8,40 @@ errlog()
        return $lastexit
 }
 
+check_commands()
+{
+       command -v scanimage > /dev/null \
+               || errlog "command scanimage not found" \
+               || return $?
+       command -v qpdf > /dev/null \
+               || errlog "command qpdf not found" \
+               || return $?
+       command -v ocrmypdf > /dev/null \
+               || errlog "command ocrmypdf not found" \
+               || return $?
+       command -v tiff2pdf > /dev/null \
+               || errlog "command tiff2pdf not found" \
+               || return $?
+       command -v pdftk > /dev/null \
+               || errlog "command pdftk not found" \
+               || return $?
+       command -v zbarimg > /dev/null \
+               || errlog "command zbarimg not found" \
+               || return $?
+       command -v tiff2pdf > /dev/null \
+               || errlog "command tiff2pdf not found" \
+               || return $?
+}
+
 optimize()
 {
        local input="$1"
        local output="$input-out"
 
-       command -v qpdf > /dev/null \
-               || errlog "command qpdf not found" \
-               || return $?
        [ -n "$input" ] \
                || errlog "missing input" \
                || return $?
+
        qpdf --linearize $input $output \
                || errlog "could not linearize $input" \
                || return $?
@@ -32,9 +55,6 @@ addocr()
        local input="$1"
        local output="$input-out"
 
-       command -v ocrmypdf > /dev/null \
-               || errlog "command ocrmypdf not found" \
-               || return $?
        [ -n "$input" ] \
                || errlog "missing input" \
                || return $?
@@ -57,12 +77,6 @@ createonepdf()
 {
        local output=$1
 
-       command -v tiff2pdf > /dev/null \
-               || errlog "command tiff2pdf not found" \
-               || return $?
-       command -v pdftk > /dev/null \
-               || errlog "command pdftk not found" \
-               || return $?
        [ -n "$output" ] \
                || errlog "missing output" \
                || return $?
@@ -100,9 +114,6 @@ createpdf()
        local pdfs=()
        basename=${basename:="out"}
 
-       command -v pdftk > /dev/null \
-               || errlog "command pdftk not found" \
-               || return $?
        [ -n "$start" ] \
                || errlog "missing start" \
                || return $?
@@ -135,9 +146,6 @@ detectsplit()
        local pdf=$1
        local trenn=
 
-       command -v zbarimg > /dev/null \
-               || errlog "command zbarimg not found" \
-               || return $?
        [ -n "$pdf" ] \
                || errlog "missing pdf" \
                || return $?
@@ -157,9 +165,6 @@ createmultipdfs()
        local startcount=1
        local endcount=1
 
-       command -v tiff2pdf > /dev/null \
-               || errlog "command tiff2pdf not found" \
-               || return $?
        [ -n "$basename" ] \
                || errlog "missing basename" \
                || return $?
@@ -197,8 +202,7 @@ scantopdf() {
        local pagecount="$2"
        local output="$3"
 
-       command -v scanimage > /dev/null \
-               || errlog "command scanimage not found" \
+       check_commands \
                || return $?
        [ -n "$mode" ] \
                || errlog "missing mode" \