Skip to content

Instantly share code, notes, and snippets.

View shirokun20's full-sized avatar
😀
ready

Shiro Mobile Dev shirokun20

😀
ready
View GitHub Profile
@bencholmes
bencholmes / count_colour_pages.sh
Created January 21, 2019 16:54
A bash script to count the number of pages in a PDF and how many are colour/black&white
FILENAME="$1"
# https://stackoverflow.com/questions/1672580/get-number-of-pages-in-a-pdf-using-a-cmd-batch-file
# Uses pdfinfo to find general information, focusing on the number of pages from which only the number is extracted.
NPAGES=$(pdfinfo "$FILENAME" | grep Pages | sed 's/[^0-9]*//')
# https://root42.blogspot.com/2012/10/counting-color-pages-in-pdf-files.html
# Uses ghostscript to measure any deviation from black in the ink colour used on pages.
GHOSTOUT=$(gs -o - -sDEVICE=inkcov $FILENAME | grep -v "^ 0.00000 0.00000 0.00000" | grep "^ " | wc -l)