aboutsummaryrefslogtreecommitdiffstats
path: root/hm/soispha/pkgs/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'hm/soispha/pkgs/scripts')
-rw-r--r--[-rwxr-xr-x]hm/soispha/pkgs/scripts/apps/con2pdf16
1 files changed, 10 insertions, 6 deletions
diff --git a/hm/soispha/pkgs/scripts/apps/con2pdf b/hm/soispha/pkgs/scripts/apps/con2pdf
index f5b3623e..23ec0ddd 100755..100644
--- a/hm/soispha/pkgs/scripts/apps/con2pdf
+++ b/hm/soispha/pkgs/scripts/apps/con2pdf
@@ -107,14 +107,13 @@ scan() {
counter=0;
image_cache="$(mktmp)"
msg "Converting images to pdfs...";
- while read -r scanned_image;do
+ while read -r scanned_image; do
+ echo "$scanned_image" >> "$image_cache"
+ : $((counter += 1))
if [ "$counter" = "$number_of_pages" ]; then
counter=0;
process_images "$image_cache" "$name" "$output_directory"
echo "" > "$image_cache"
- else
- echo "$scanned_image" >> "$image_cache"
- : $((counter += 1))
fi
done < "$(tmp fd . "$tiff_temp_path" "|" sort -n)"
}
@@ -124,12 +123,16 @@ process_images() {
name="$2";
output_dir="$3";
- set -- ""
+ set --
while read -r image; do
set -- "$@" "$image"
done < "$image_cache"
- convert "$@" -compress jpeg -quality 100 "$output_dir/${name}_${counter}.pdf"
+ while [ -e "$output_dir/${name}.pdf" ]; do
+ name="${name}_$(tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 25)"
+ done
+
+ convert "$@" -compress jpeg -quality 100 "$output_dir/${name}.pdf"
}
for input in "$@"; do
@@ -184,3 +187,4 @@ while [ "$#" -ne 0 ]; do
shift 1;
done
scan "$number_of_pages" "$device" "$output_directory" "$name" "$method";
+