#! /bin/bash # This script tests: pamchannel # Also requires: pamtopam pamtopnm # Extract planes one by one. # Convert output to pgm to make it identical to ppmtorgb3 output. # $ ppmtorgb3 testimg.ppm ; cksum testimg.{red,grn,blu} # # 1571496937 33838 testimg.red # 394856971 33838 testimg.grn # 3164158573 33838 testimg.blu # Test 1. red channel # Should produce 1571496937 33838 echo "Test 1" pamchannel -infile testimg.ppm 0 | \ pamtopnm --assume | cksum # Test 2. green channel # Should produce 394856971 33838 echo "Test 2" pamchannel -infile testimg.ppm -tupletype="GRAYSCALE" 1 | \ pamtopnm | cksum # Test 3. blue channel # Should produce 3164158573 33838 echo "Test 3" pamchannel -infile testimg.ppm 2 | \ pamtopnm --assume | cksum # Test invalid: specified channel does not exist echo 1>&2 echo "Invalid command-line argument combinations." 1>&2 echo "Error messages should appear below the line." 1>&2 echo "-----------------------------------------------------------" 1>&2 tmpdir=${tmpdir:-/tmp} test_out=${tmpdir}/test_out echo "Test Invalid" pamchannel -infile testgrid.pbm 1 > ${test_out} || \ echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? pamchannel -infile testimg.ppm 3 > ${test_out} || \ echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? pamtopam testimg.ppm | pamchannel -infile=- 4 > ${test_out} || \ echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? rm ${test_out}