diff options
author | Soispha <soispha@vhack.eu> | 2023-11-25 16:17:36 +0100 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-11-25 16:17:36 +0100 |
commit | d2cd29223d90aa13944ba03c4e0f5173e19c1188 (patch) | |
tree | d7e4b9270998a3d5aea5d5fef742705d1d7b447f | |
parent | fix(hm/pkgs/src/con2pdf): Fully support n pages, instead of 2 (diff) | |
download | nixos-config-d2cd29223d90aa13944ba03c4e0f5173e19c1188.tar.gz nixos-config-d2cd29223d90aa13944ba03c4e0f5173e19c1188.zip |
fix(hm/pkgs/scr/con2pdf): Fix command usage errors
Diffstat (limited to '')
-rw-r--r--[-rwxr-xr-x] | hm/soispha/pkgs/scripts/apps/con2pdf | 16 |
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"; + |