From: Bastian Dehn Date: Fri, 21 Nov 2025 18:22:31 +0000 (+0100) Subject: change optimize create multi pdf X-Git-Tag: v1.1.3^2~16 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=855481345b9d2050b5a5630f8d1217cfab78ca75;p=scantopdf.git change optimize create multi pdf --- diff --git a/src/scanbasic.sh b/src/scanbasic.sh index 682363d..b237690 100644 --- a/src/scanbasic.sh +++ b/src/scanbasic.sh @@ -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 diff --git a/tests/scanbasic.bats b/tests/scanbasic.bats index b920b2b..31a4c81 100755 --- a/tests/scanbasic.bats +++ b/tests/scanbasic.bats @@ -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() { :