Skip to content

Commit

Permalink
Faster mergepdf processing
Browse files Browse the repository at this point in the history
and fix tiffs with no levels
  • Loading branch information
joecorall authored Nov 20, 2024
1 parent 49b783b commit f5a3271
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/mergepdf/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ while read -r URL; do
# If we have reached the max thread limit, wait for any one job to finish
if [ "${#PIDS[@]}" -ge "$MAX_THREADS" ]; then
wait -n
NEW_PIDS=()
for pid in "${PIDS[@]}"; do
if kill -0 "$pid" 2>/dev/null; then
NEW_PIDS+=("$pid")
fi
done
PIDS=("${NEW_PIDS[@]}")
fi

# Run each job in the background
(
# download and resize image to max 1000px width
curl -s "$URL" | magick -[0] -resize 1000x\> "$TMP_DIR/img_$I" > /dev/null 2>&1
curl -s "$URL" | magick -[0] -resize 1000x\> "$TMP_DIR/img_$I" || curl -s "$URL" | magick - -resize 1000x\> "$TMP_DIR/img_$I" > /dev/null 2>&1
# make an OCR'd PDF from the image
tesseract "$TMP_DIR/img_$I" "$TMP_DIR/img_$I" pdf > /dev/null 2>&1
rm "$TMP_DIR/img_$I"
Expand Down

0 comments on commit f5a3271

Please sign in to comment.