Created
February 1, 2021 17:22
-
-
Save innermond/73412a5824127b6adfc99d450b324deb to your computer and use it in GitHub Desktop.
calculate median ink coverage of all pages from a pdf FILE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z $1 ]; then echo "introdu cale fisier"; exit 1; fi | |
covfile=${1%.*}.cov | |
# run this block in background | |
{ | |
gs -o - -sDEVICE=inkcov "$1" > "$covfile" | |
sed -i -E '/^\S/d' "$covfile" | |
awk '{c+=$1; m+=$2; y+=$3; k+=$4; next} END{c=c/NR; m=m/NR; y=y/NR; k=k/NR; print "C="c " M="m " Y="y " K="k " T="c+m+y+k}' "$covfile" | |
if [ ! -z "$2" ]; then | |
rm "$covfile"; | |
fi | |
} & | |
# wait here for completion of block above | |
pid=$! # Process Id of the previous running command | |
spin='—\|/' | |
i=0 | |
while kill -0 $pid 2>/dev/null | |
do | |
i=$(( (i+1) %4 )) | |
printf "\r${spin:$i:1}" | |
sleep .1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment