Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using scanimage with a document scanner (Canon DR-2510C) that supports duplex scanning. Unfortunately, its SANE driver does not support blank page detection, so that with mixed pages (single/double-sided), blank pages make it into the scan result.

I would like to automatically get rid of those blank pages when post-processing the scan output, so I am looking for a command-line tool that is able to detect whether a TIFF or PNM file consists of mostly white pixels).

Any ideas?

This is the solution I came up with based on the answer by lesmana:

for i in "${DEST_DIR}/out"*.pnm; do
  histogram=`convert "${i}" -threshold 50% -format %c histogram:info:-`
  white=`echo "${histogram}" | grep "white" | sed -n 's/^ *\(.*\):.*$/\1/p'`
  black=`echo "${histogram}" | grep "black" | sed -n 's/^ *\(.*\):.*$/\1/p'`
  blank=`echo "scale=4; ${black}/${white} < 0.005" | bc`
  if [ ${blank} -eq "1" ]; then
    echo "${i} seems to be blank - removing it..."
    rm "${i}"
share|improve this question

2 Answers 2

up vote 0 down vote accepted

You can use ImageMagick compare tool to compare the scanned images against a "master" blank page. Since my ImageMagick-fu is quite limited I cannot give you any example command. You will have to RTFM:

The second link even has a section titled "Blank Fax" which explains how to detect blank fax pages. Sadly that section seems unfinished. Hopefully the available information is enough for you to get started.

share|improve this answer

Use the identify feature of ImageMagik CLI as given here:


With command:

$ identify -format "%#" source.png

If the number of colors is 1, you have a blank page.

You can also use the command:

identify -verbose source.png

The standard deviation, skew and kurtosis will be 0 for a blank image.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.