]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
change optimize create multi pdf
authorBastian Dehn <hhaalo@arcor.de>
Fri, 21 Nov 2025 18:22:31 +0000 (19:22 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 21 Nov 2025 18:22:31 +0000 (19:22 +0100)
src/scanbasic.sh
tests/scanbasic.bats

index 682363dc40b335ef898e9fc831f301b0281529a3..b2376909910c684819b4df32cc4a744e5e903796 100644 (file)
@@ -31,6 +31,12 @@ check_commands()
        command -v exiftool > /dev/null \
                || errlog "command exiftool not found" \
                || return $?
+       command -v parallel > /dev/null \
+               || errlog "command parallel not found" \
+               || return $?
+       command -v find > /dev/null \
+               || errlog "command find not found" \
+               || return $?
 }
 
 optimize()
@@ -164,23 +170,11 @@ createmultipdfs()
                || errlog "missing basename" \
                || return $?
 
-       local pdf=
-       local tiff=
-       for tiff in scanned-$$-*.tiff; do
-               pdf=${tiff/.tiff/.pdf}
-               tiff2pdf $tiff -o $pdf \
-                       || errlog "could not convert $tiff to $pdf" \
-                       || return $?
-               rm $tiff \
-                       || errlog "could not delete $tiff" \
-                       || return $?
-       done
-
-       local pdffile=
-       for pdffile in scanned-$$-*.pdf; do
-               addocr "$pdffile" \
-                       || return $?
-       done
+       find scanned-$$-*.tiff | parallel tiff2pdf {} -o {.}.pdf
+       rm scanned-$$-*.tiff
+       export -f addocr
+       export -f optimize
+       find scanned-$$-*.pdf | parallel addocr {}
 
        local startcount=1
        local endcount=1
index b920b2b857e8aeebd0e2e762bf96b9067a85b21f..31a4c8151cab6c910082343cc180a54d26158ca7 100755 (executable)
@@ -218,16 +218,6 @@ setup() {
        assert_line --index 0 "true"
 }
 
-@test "should failure createmultipdfs tiff2pdf fails" {
-       tiff2pdf() {
-               return 1
-       }
-
-       run createmultipdfs
-
-       assert_failure
-}
-
 @test "should success createmutlipdfs" {
        tiff2pdf() {
                :