about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Test-Order10
-rw-r--r--test/all-in-place.ok2
-rwxr-xr-xtest/all-in-place.test13
-rw-r--r--test/atari-roundtrip.ok3
-rwxr-xr-xtest/atari-roundtrip.test40
-rw-r--r--test/cis-roundtrip.ok2
-rwxr-xr-xtest/cis-roundtrip.test20
-rw-r--r--test/facesaver-roundtrip.ok2
-rwxr-xr-xtest/facesaver-roundtrip.test7
-rwxr-xr-xtest/gif-quant-roundtrip.test11
-rw-r--r--test/gif-roundtrip.ok8
-rwxr-xr-xtest/gif-roundtrip.test62
-rw-r--r--test/ilbm-roundtrip.ok1
-rwxr-xr-xtest/ilbm-roundtrip.test20
-rw-r--r--test/jbig-roundtrip.ok2
-rwxr-xr-xtest/jbig-roundtrip.test8
-rw-r--r--test/macp-roundtrip.ok2
-rwxr-xr-xtest/macp-roundtrip.test15
-rw-r--r--test/mda-roundtrip.ok2
-rwxr-xr-xtest/mda-roundtrip.test19
-rwxr-xr-xtest/pamchannel.test5
-rw-r--r--test/pamcrater.ok6
-rwxr-xr-xtest/pamcrater.test53
-rwxr-xr-xtest/pamdice-roundtrip.test9
-rw-r--r--test/pamditherbw.ok8
-rwxr-xr-xtest/pamditherbw.test27
-rw-r--r--test/pamenlarge.ok2
-rwxr-xr-xtest/pamenlarge.test8
-rw-r--r--test/pamfile.ok2
-rwxr-xr-xtest/pamfile.test9
-rwxr-xr-x[-rw-r--r--]test/pamflip1.test0
-rwxr-xr-x[-rw-r--r--]test/pamflip2.test0
-rwxr-xr-xtest/pamslice-roundtrip.test26
-rwxr-xr-xtest/pbmclean.test10
-rw-r--r--test/pcx-roundtrip.ok5
-rwxr-xr-xtest/pcx-roundtrip.test49
-rw-r--r--test/pgmbentley.ok1
-rwxr-xr-xtest/pgmbentley.test10
-rwxr-xr-xtest/pgmtoppm.test17
-rw-r--r--test/pi3-roundtrip.ok2
-rwxr-xr-xtest/pi3-roundtrip.test22
-rw-r--r--test/pict-roundtrip.ok1
-rwxr-xr-xtest/pict-roundtrip.test15
-rw-r--r--test/pnminvert.ok2
-rwxr-xr-xtest/pnminvert.test18
-rwxr-xr-xtest/pnmpsnr.test18
-rwxr-xr-xtest/pnmremap1.test16
-rwxr-xr-xtest/pnmremap2.test17
-rwxr-xr-xtest/pnmtile.test18
-rwxr-xr-xtest/ppmcie.test16
-rwxr-xr-xtest/ppmdim.test13
-rwxr-xr-xtest/ppmmix.test23
-rwxr-xr-xtest/ps-alt-roundtrip.test33
-rwxr-xr-xtest/ps-roundtrip.test53
-rwxr-xr-xtest/rgb3-roundtrip.test39
-rw-r--r--test/sgi-roundtrip.ok6
-rwxr-xr-xtest/sgi-roundtrip.test38
-rw-r--r--test/targa-roundtrip.ok2
-rwxr-xr-xtest/targa-roundtrip.test13
-rw-r--r--test/utahrle-roundtrip.ok2
-rwxr-xr-xtest/utahrle-roundtrip.test12
-rw-r--r--test/xwd-roundtrip.ok2
-rwxr-xr-xtest/xwd-roundtrip.test10
63 files changed, 665 insertions, 222 deletions
diff --git a/test/Test-Order b/test/Test-Order
index 9a9210e4..cc79570e 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -16,12 +16,12 @@ pgmramp.test
 ppmgauss.test
 ppmcie.test
 ppmwheel.test
+pamcrater.test
 
 # Generators with random components
 
 pgmnoise.test
 ppmpat.test
-pgmcrater.test
 ppmforge.test
 ppmrough.test
 
@@ -66,6 +66,7 @@ ppmrelief.test
 pamedge.test
 ppmdim.test
 pnmshear.test
+pgmbentley.test
 
 ppmmix.test
 
@@ -99,9 +100,11 @@ pamslice-roundtrip.test
 
 # Round-trip tests : lossless converters
 
+atari-roundtrip.test
 atk-roundtrip.test
 avs-roundtrip.test
 bmp-roundtrip.test
+cis-roundtrip.test
 cmuw-roundtrip.test
 facesaver-roundtrip.test
 fits-roundtrip.test
@@ -112,12 +115,17 @@ gif-quant-roundtrip.test
 hdiff-roundtrip.test
 jbig-roundtrip.test
 leaf-roundtrip.test
+mda-roundtrip.test
 mgr-roundtrip.test
 mrf-roundtrip.test
+pcx-roundtrip.test
 pfm-roundtrip.test
+pi3-roundtrip.test
+pict-roundtrip.test
 png-roundtrip.test
 ps-roundtrip.test
 ps-alt-roundtrip.test
+sgi-roundtrip.test
 sunrast-roundtrip.test
 targa-roundtrip.test
 tiff-roundtrip.test
diff --git a/test/all-in-place.ok b/test/all-in-place.ok
index ca8ad8c3..d37fd561 100644
--- a/test/all-in-place.ok
+++ b/test/all-in-place.ok
@@ -161,7 +161,7 @@ pdbimgtopam: ok
 pfmtopam: ok
 pgmabel: ok
 pgmbentley: ok
-pgmcrater: ok
+pamcrater: ok
 pgmdeshadow: ok
 pgmedge: ok
 pgmenhance: ok
diff --git a/test/all-in-place.test b/test/all-in-place.test
index 87ddfad8..d6ccdb3c 100755
--- a/test/all-in-place.test
+++ b/test/all-in-place.test
@@ -200,7 +200,7 @@ ordinary_testprogs="\
   pfmtopam \
   pgmabel \
   pgmbentley \
-  pgmcrater \
+  pamcrater \
   pgmdeshadow \
   pgmedge \
   pgmenhance \
@@ -408,7 +408,10 @@ ${PBM_TESTPREFIX}pnmmargin --help 2> /dev/null
 # pnmtoplainpnm, ppmquantall, ppmrainbow, ppmshadow, ppmtomap
 # with trivial input.
 
-cat > ${tmpdir}/test.pbm <<EOF
+tmpdir=${tmpdir:-/tmp}
+test_pbm=${tmpdir}/test.pbm
+
+cat > ${test_pbm} <<EOF
 P1
 1 1
 1
@@ -416,17 +419,17 @@ EOF
 
 for i in anytopnm pbmtox10bm pnmnoraw pnmtoplainpnm ppmtomap ppmshadow
   do
-    ${PBM_TESTPREFIX}$i ${tmpdir}/test.pbm > /dev/null 2> /dev/null;
+    ${PBM_TESTPREFIX}$i ${test_pbm} > /dev/null 2> /dev/null;
     testExitStatus $i 0 $?
   done
 
 for i in pnmquant pnmquantall ppmquant ppmquantall
   do
-    ${PBM_TESTPREFIX}$i 2 ${tmpdir}/test.pbm > /dev/null 2> /dev/null;
+    ${PBM_TESTPREFIX}$i 2 ${test_pbm} > /dev/null 2> /dev/null;
     testExitStatus $i 0 $?
   done
 
-rm ${tmpdir}/test.pbm
+rm ${test_pbm}
 
 ${PBM_TESTPREFIX}ppmrainbow rgb:00/00/00 rgb:ff/ff/ff \
     -tmpdir=${tmpdir} -width=2 -height=2 > /dev/null
diff --git a/test/atari-roundtrip.ok b/test/atari-roundtrip.ok
new file mode 100644
index 00000000..48b8a30a
--- /dev/null
+++ b/test/atari-roundtrip.ok
@@ -0,0 +1,3 @@
+3583332118 192013
+3583332118 192013
+3583332118 192013
diff --git a/test/atari-roundtrip.test b/test/atari-roundtrip.test
new file mode 100755
index 00000000..85929a8b
--- /dev/null
+++ b/test/atari-roundtrip.test
@@ -0,0 +1,40 @@
+# This script tests: ppmtopi1 pi1toppm ppmtoneo neotoppm
+# Also requires: pgmramp pamscale pbmmake rgb3toppm
+
+  alias ppmtopi1="${PBM_TESTPREFIX}ppmtopi1"
+  alias pi1toppm="${PBM_TESTPREFIX}pi1toppm"
+  alias ppmtoneo="${PBM_TESTPREFIX}ppmtoneo"
+  alias neotoppm="${PBM_TESTPREFIX}neotoppm"
+  alias pgmramp="${PBM_BINPREFIX}pgmramp"
+  alias pamscale="${PBM_BINPREFIX}pamscale"
+  alias pbmmake="${PBM_BINPREFIX}pbmmake"
+  alias rgb3toppm="${PBM_BINPREFIX}rgb3toppm"
+  shopt -s expand_aliases
+
+# Atari pi1 and neo files have the following characteristics:
+# Size: 320x200
+# Maxval: 7
+# Color palette: at most 16 entries
+
+tmpdir=${tmpdir:-/tmp}
+t_red=${tmpdir}/t.red
+t_grn=${tmpdir}/t.grn
+t_blu=${tmpdir}/t.blu
+t_ppm=${tmpdir}/t.ppm
+
+pgmramp -lr -maxval=3 4 1 | \
+  pamscale -xscale=80 -yscale=200 -nomix  > ${t_red}
+pbmmake -g 16 10 | pamenlarge 20  > ${t_grn}
+pbmmake -g  8  5 | pamenlarge 40  > ${t_blu}
+rgb3toppm ${t_red} ${t_grn} ${t_blu} | pamdepth 7 > ${t_ppm}
+
+#Test 0.  Should print: 3583332118 192013
+cksum < ${t_ppm}
+
+#Test 1.  Should print: 3583332118 192013
+ppmtopi1 ${t_ppm} | pi1toppm | cksum
+
+#Test 2.  Should print: 3583332118 192013
+ppmtoneo ${t_ppm} | neotoppm | cksum
+
+rm ${t_red} ${t_grn} ${t_blu} ${t_ppm}
diff --git a/test/cis-roundtrip.ok b/test/cis-roundtrip.ok
new file mode 100644
index 00000000..da90078b
--- /dev/null
+++ b/test/cis-roundtrip.ok
@@ -0,0 +1,2 @@
+2631579683 1546
+2425386270 41
diff --git a/test/cis-roundtrip.test b/test/cis-roundtrip.test
new file mode 100755
index 00000000..895fe60e
--- /dev/null
+++ b/test/cis-roundtrip.test
@@ -0,0 +1,20 @@
+#! /bin/bash
+# This script tests: pbmtocis cistopbm
+# Also requires: pbmmake pamenlarge pamcut
+
+  alias pbmtocis="${PBM_TESTPREFIX}pbmtocis"
+  alias cistopbm="${PBM_TESTPREFIX}cistopbm"
+  alias pbmmake="${PBM_BINPREFIX}pbmmake"
+  alias pamenlarge="${PBM_BINPREFIX}pamenlarge"
+  alias pamcut="${PBM_BINPREFIX}pamcut"
+  shopt -s expand_aliases
+
+# Output images produced by pbmtocis are of fixed size,
+# either 128x96 or 256x192.
+# Smaller input images are padded, larger ones are cropped.
+
+# Test 1. Should print 2631579683 1546
+pbmmake -g 128 96 | pbmtocis | cistopbm | cksum
+
+# Test 2. Should print 2425386270 41
+pbmtocis testgrid.pbm | cistopbm | pamcut 0 0 14 16 | cksum
diff --git a/test/facesaver-roundtrip.ok b/test/facesaver-roundtrip.ok
index 32a4743b..430f3f5f 100644
--- a/test/facesaver-roundtrip.ok
+++ b/test/facesaver-roundtrip.ok
@@ -1 +1 @@
-2871603838 33838
+1571496937 33838
diff --git a/test/facesaver-roundtrip.test b/test/facesaver-roundtrip.test
index 362edaf5..76de380d 100755
--- a/test/facesaver-roundtrip.test
+++ b/test/facesaver-roundtrip.test
@@ -1,13 +1,12 @@
 #! /bin/bash
 # This script tests: pgmtofs fstopgm
-# Also requires: ppmtopgm
+# Also requires: pamchannel
 
   alias fstopgm="${PBM_TESTPREFIX}fstopgm"
   alias pgmtofs="${PBM_TESTPREFIX}pgmtofs"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
-# Should produce 2871603838 33838, cksum of testimg.pgm
+# Should produce 1571496937 33838, cksum of testimg.red
 
-ppmtopgm testimg.ppm | \
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
   pgmtofs | fstopgm | cksum
diff --git a/test/gif-quant-roundtrip.test b/test/gif-quant-roundtrip.test
index b5f69edd..7f99ca6e 100755
--- a/test/gif-quant-roundtrip.test
+++ b/test/gif-quant-roundtrip.test
@@ -11,10 +11,13 @@
 
 colors=15      # any value between 2 - 256 works
 
-pnmquant $colors testimg.ppm > ${tmpdir}/quant.ppm &&
-pamtogif ${tmpdir}/quant.ppm | giftopnm | \
-   cmp -s - ${tmpdir}/quant.ppm > /dev/null
+tmpdir=${tmpdir:-/tmp}
+quant_ppm=${tmpdir}/quant.ppm
+
+pnmquant ${colors} testimg.ppm > ${quant_ppm} &&
+pamtogif ${quant_ppm} | giftopnm | \
+   cmp -s - ${quant_ppm} > /dev/null
 echo $?
 
-rm ${tmpdir}/quant.ppm
+rm ${quant_ppm}
 
diff --git a/test/gif-roundtrip.ok b/test/gif-roundtrip.ok
index ece7593c..552bf90c 100644
--- a/test/gif-roundtrip.ok
+++ b/test/gif-roundtrip.ok
@@ -1,8 +1,8 @@
-2871603838 33838
-2871603838 33838
-2871603838 33838
-2871603838 33838
 1926073387 101484
+1571496937 33838
+1571496937 33838
+1571496937 33838
+1571496937 33838
 2425386270 41
 2425386270 41
 2425386270 41
diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test
index 574638ac..cb62bfb1 100755
--- a/test/gif-roundtrip.test
+++ b/test/gif-roundtrip.test
@@ -1,47 +1,59 @@
 #! /bin/bash
 # This script tests: giftopnm pamtogif
-# Also requires: ppmtopgm ppmtorgb3 rgb3toppm pbmmake
+# Also requires: ppmtorgb3 rgb3toppm pbmmake
 
   alias giftopnm="${PBM_TESTPREFIX}giftopnm"
   alias pamtogif="${PBM_TESTPREFIX}pamtogif"
   alias pbmmake="${PBM_BINPREFIX}pbmmake"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   alias ppmtorgb3="${PBM_BINPREFIX}ppmtorgb3"
   alias rgb3toppm="${PBM_BINPREFIX}rgb3toppm"
   alias pnminvert="${PBM_BINPREFIX}pnminvert"
   shopt -s expand_aliases
 
-# Test 1. Should produce 2871603838 33838
-# which is the result of ppmtopgm testimg.ppm | cksum
-# four times
-
-ppmtopgm testimg.ppm | tee ${tmpdir}/testimg.pgm | pamtogif | giftopnm | cksum
-pamtogif -interlace ${tmpdir}/testimg.pgm | giftopnm | cksum
-pamtogif -sort ${tmpdir}/testimg.pgm | tee ${tmpdir}/testimg.gif | \
-  giftopnm | cksum
-echo "junk" >> ${tmpdir}/testimg.gif && \
-  giftopnm -image=1 -quitearly ${tmpdir}/testimg.gif | cksum
-
-rm  ${tmpdir}/testimg.pgm
-rm  ${tmpdir}/testimg.gif
+tmpdir=${tmpdir:-/tmp}
 
-# Test 2. Break up input image into three monochrome planes,
+# Test 1. Break up input image into three monochrome planes,
 # maxval 255.  Transform each plane to gif and back to pgm.
 # Reassemble the planes.  Result should be identical to input.
 # Should print 1926073387 101484
 
+test_ppm=${tmpdir}/testimg.ppm
+
 cp testimg.ppm ${tmpdir} &&
-ppmtorgb3 ${tmpdir}/testimg.ppm &&
-pamtogif ${tmpdir}/testimg.red | \
-  giftopnm > ${tmpdir}/out.red &&
-pamtogif ${tmpdir}/testimg.grn |
-  giftopnm > ${tmpdir}/out.grn &&
-pamtogif ${tmpdir}/testimg.blu | \
-  giftopnm | \
-  rgb3toppm ${tmpdir}/testimg.red ${tmpdir}/testimg.grn - | \
+ppmtorgb3 ${test_ppm} &&
+
+test_red=${tmpdir}/testimg.red
+test_grn=${tmpdir}/testimg.grn
+test_blu=${tmpdir}/testimg.blu
+out_red=${tmpdir}/out.red
+out_grn=${tmpdir}/out.grn
+out_blu=${tmpdir}/out.blu
+
+pamtogif ${test_red} | giftopnm > ${out_red} &&
+pamtogif ${test_grn} | giftopnm > ${out_grn} &&
+pamtogif ${test_blu} | giftopnm | \
+  rgb3toppm ${out_red} ${out_grn} - | \
   cksum
 
-rm ${tmpdir}/testimg.{ppm,red,grn,blu} ${tmpdir}/out.{red,grn}
+rm ${test_ppm} ${test_grn} ${test_blu} \
+   ${out_red} ${out_grn} ${out_blu}
+
+
+# Test 2. Should produce 1571496937 33838
+# which is the result of cksum testimg.red
+# four times
+
+test_gif=${tmpdir}/testimg.gif
+
+pamtogif ${test_red} | giftopnm | cksum
+pamtogif -interlace ${test_red} | giftopnm | cksum
+pamtogif -sort ${test_red} | tee ${test_gif} | \
+  giftopnm | cksum
+echo "junk" >> ${test_gif} && \
+  giftopnm -image=1 -quitearly ${test_gif} | cksum
+
+rm  ${test_gif} ${test_red}
+
 
 # Test 3. Should produce 2425386270 41 five times.
 
diff --git a/test/ilbm-roundtrip.ok b/test/ilbm-roundtrip.ok
new file mode 100644
index 00000000..82eac5a8
--- /dev/null
+++ b/test/ilbm-roundtrip.ok
@@ -0,0 +1 @@
+1926073387 101484
diff --git a/test/ilbm-roundtrip.test b/test/ilbm-roundtrip.test
new file mode 100755
index 00000000..495daf53
--- /dev/null
+++ b/test/ilbm-roundtrip.test
@@ -0,0 +1,20 @@
+#! /bin/bash
+# This script tests: ppmtoilbm ilbmtoppm
+# Also requires: pamseq pamdepth pamtopnm pnmremap
+
+  alias ppmtoilbm="${PBM_TESTPREFIX}ppmtoilbm"
+  alias ilbmtoppm="${PBM_TESTPREFIX}ilbmtoppm"
+  alias pamseq="${PBM_BINPREFIX}pamseq"
+  alias pamdepth="${PBM_BINPREFIX}pamdepth"
+  alias pamtopnm="${PBM_BINPREFIX}pamtopnm"
+  alias pnmremap="${PBM_BINPREFIX}pnmremap"
+  shopt -s expand_aliases
+
+#Test.  Should produce 1926073387 101484
+ppmtoilbm testimg.ppm | ilbmtoppm | cksum
+
+#Test.  Should print 984199586 101484
+pamseq 3 5 -tupletype=RGB | pamdepth 255 | pamtopnm | \
+  pnmremap -mapfile=- testimg.ppm | ppmtoilbm | ilbmtoppm | cksum
+
+
diff --git a/test/jbig-roundtrip.ok b/test/jbig-roundtrip.ok
index a951db19..b98a694b 100644
--- a/test/jbig-roundtrip.ok
+++ b/test/jbig-roundtrip.ok
@@ -1,2 +1,2 @@
 2425386270 41
-2871603838 33838
+1571496937 33838
diff --git a/test/jbig-roundtrip.test b/test/jbig-roundtrip.test
index 766148c6..9ce23f51 100755
--- a/test/jbig-roundtrip.test
+++ b/test/jbig-roundtrip.test
@@ -1,14 +1,14 @@
 #! /bin/bash
 # This script tests: pnmtojbig jbigtopnm
-# Also requires: ppmtopgm
+# Also requires: pamchannel
 
   alias pnmtojbig="${PBM_TESTPREFIX}pnmtojbig"
   alias jbigtopnm="${PBM_TESTPREFIX}jbigtopnm"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
 # Test 1.  Should print 2425386270 41
 pnmtojbig testgrid.pbm | jbigtopnm | cksum
 
-# Test 2.  Should print 2871603838 33838
-ppmtopgm testimg.ppm | pnmtojbig | jbigtopnm | cksum
\ No newline at end of file
+# Test 2.  Should print 1571496937 33838
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  pnmtojbig | jbigtopnm | cksum
diff --git a/test/macp-roundtrip.ok b/test/macp-roundtrip.ok
new file mode 100644
index 00000000..20e24348
--- /dev/null
+++ b/test/macp-roundtrip.ok
@@ -0,0 +1,2 @@
+2425386270 41
+1005016577 51851
diff --git a/test/macp-roundtrip.test b/test/macp-roundtrip.test
new file mode 100755
index 00000000..39228e5a
--- /dev/null
+++ b/test/macp-roundtrip.test
@@ -0,0 +1,15 @@
+#! /bin/bash
+# This script tests: pbmtomacp macptopbm
+# Also requires: pamcrop pbmmake
+
+  alias pbmtomacp="${PBM_TESTPREFIX}pbmtomacp"
+  alias macptopbm="${PBM_TESTPREFIX}macptopbm"
+  alias pnmcrop="${PBM_BINPREFIX}pnmcrop"
+  alias pbmmake="${PBM_BINPREFIX}pbmmake"
+  shopt -s expand_aliases
+
+#Test 1. Should produce 2425386270 41
+pbmtomacp testgrid.pbm | macptopbm | pnmcrop | cksum
+
+#Test 2. Should produce 1005016577 51851
+pbmmake -g 576 720 | pbmtomacp | macptopbm | cksum
diff --git a/test/mda-roundtrip.ok b/test/mda-roundtrip.ok
new file mode 100644
index 00000000..ef27ffd0
--- /dev/null
+++ b/test/mda-roundtrip.ok
@@ -0,0 +1,2 @@
+1757803444 169
+2425386270 41
diff --git a/test/mda-roundtrip.test b/test/mda-roundtrip.test
new file mode 100755
index 00000000..3bde61ee
--- /dev/null
+++ b/test/mda-roundtrip.test
@@ -0,0 +1,19 @@
+#! /bin/bash
+# This script tests: pbmtomda mdatopbm
+# Also requires: pbmmake pnmpad pamcut
+
+  alias pbmtomda="${PBM_TESTPREFIX}pbmtomda"
+  alias mdatopbm="${PBM_TESTPREFIX}mdatopbm"
+  alias pbmmake="${PBM_BINPREFIX}pbmmake"
+  alias pnmpad="${PBM_BINPREFIX}pnmpad"
+  alias pamcut="${PBM_BINPREFIX}pamcut"
+  shopt -s expand_aliases
+
+# Pbmtomda requires input width and height to be multiples of 8. 
+
+# Test 1.  Should print 1757803444 169
+pbmmake -g 32 40 | pbmtomda | mdatopbm | cksum
+
+# Test 2.  Should print 2425386270 41
+pnmpad -right 2 testgrid.pbm | \
+  pbmtomda | mdatopbm | pamcut 0 0 14 16 | cksum
diff --git a/test/pamchannel.test b/test/pamchannel.test
index e3da552c..9ac71f13 100755
--- a/test/pamchannel.test
+++ b/test/pamchannel.test
@@ -6,7 +6,6 @@
   alias pamtopnm="${PBM_BINPREFIX}pamtopnm"
   shopt -s expand_aliases
 
-
 # Extract planes one by one.
 # Convert output to pgm to make it identical to ppmtorgb3 output.
 
@@ -26,8 +25,8 @@ pamchannel -infile testimg.ppm 0 | \
 # Test 2. green channel
 # Should produce  394856971 33838
 
-pamchannel -infile testimg.ppm 1 | \
-  pamtopnm --assume | cksum
+pamchannel -infile testimg.ppm -tupletype="GRAYSCALE" 1 | \
+  pamtopnm | cksum
 
 # Test 3. blue channel
 # Should produce 3164158573 33838
diff --git a/test/pamcrater.ok b/test/pamcrater.ok
new file mode 100644
index 00000000..cfb186a6
--- /dev/null
+++ b/test/pamcrater.ok
@@ -0,0 +1,6 @@
+4
+4
+4
+2
+2
+2
diff --git a/test/pamcrater.test b/test/pamcrater.test
new file mode 100755
index 00000000..1d182208
--- /dev/null
+++ b/test/pamcrater.test
@@ -0,0 +1,53 @@
+#! /bin/bash
+# This script tests: pamcrater pamshadedrelief
+# Also requires: pamslice pamvalidate
+
+  alias pamcrater="${PBM_TESTPREFIX}pamcrater"
+  alias pamslice="${PBM_TESTPREFIX}pamshadedrelief"
+  alias pamslice="${PBM_BINPREFIX}pamslice"
+  alias pamvalidate="${PBM_TESTPREFIX}pamvalidate"
+  shopt -s expand_aliases
+
+tmpdir=${tmpdir:-/tmp}
+
+test_pam=${tmpdir}/test.pam
+testshaded_pam=${tmpdir}/testshaded_pam
+test10_pam=${tmpdir}/test10.pam
+test50_pam=${tmpdir}/test50.pam
+test100_pam=${tmpdir}/test100.pam
+test150_pam=${tmpdir}/test150.pam
+
+# Test 1.  Should print 4 three times
+
+pamcrater --test --radius=10 > $test10_pam
+pamcrater --test --radius=50 > $test50_pam
+pamcrater --test --radius=100 > $test100_pam
+pamcrater --test --radius=150 > $test150_pam
+
+pamstack ${test10_pam} ${test50_pam} ${test100_pam} ${test150_pam} |
+  pamvalidate > ${test_pam} 
+
+for i in 1 10 70
+  do
+    ( pamslice -row=$((128 + $i))  ${test_pam} | cksum &&
+      pamslice -row=$((128 - $i))  ${test_pam} | cksum &&
+      pamslice -col=$((128 + $i))  ${test_pam} | cksum &&
+      pamslice -col=$((128 - $i))  ${test_pam} | cksum
+    ) | uniq -c | awk '{print $1}'
+  done
+
+rm ${test_pam} ${test10_pam} ${test50_pam}
+
+# Test 2.  Should print 2 three times
+
+pamshadedrelief ${test100_pam} > ${testshaded_pam}
+
+( pamslice -row=$((128 + 12))  ${testshaded_pam} | cksum &&
+  pamslice -row=$((128 - 12))  ${testshaded_pam} | cksum &&
+  pamslice -row=$((128 + 31))  ${testshaded_pam} | cksum &&
+  pamslice -row=$((128 - 31))  ${testshaded_pam} | cksum &&
+  pamslice -row=$((128 + 99))  ${testshaded_pam} | cksum &&
+  pamslice -row=$((128 - 99))  ${testshaded_pam} | cksum
+) | uniq -c | awk '{print $1}'
+
+rm ${testshaded_pam} ${test100_pam}
diff --git a/test/pamdice-roundtrip.test b/test/pamdice-roundtrip.test
index 7319249a..7b863bca 100755
--- a/test/pamdice-roundtrip.test
+++ b/test/pamdice-roundtrip.test
@@ -6,8 +6,11 @@
   alias pamundice="${PBM_TESTPREFIX}pamundice"
   shopt -s expand_aliases
 
-pamdice testimg.ppm -outstem=${tmpdir}/a -width=50 -height=40
-pamundice ${tmpdir}/a_%1d_%1a.ppm -down=4 -across=5 | cksum
+tmpdir=${tmpdir:-/tmp}
+fname_stem=${tmpdir}/a
 
-rm ${tmpdir}/a_?_?.ppm
+pamdice testimg.ppm -outstem=${fname_stem} -width=50 -height=40
+pamundice ${fname_stem}_%1d_%1a.ppm -down=4 -across=5 | cksum
+
+rm ${fname_stem}_?_?.ppm
 
diff --git a/test/pamditherbw.ok b/test/pamditherbw.ok
index 0711fa38..e8186c24 100644
--- a/test/pamditherbw.ok
+++ b/test/pamditherbw.ok
@@ -1,4 +1,4 @@
-1421025574 33894
-164421928 33894
-486487763 33894
-3606822102 33894
+1316122660 33894
+3342429190 33894
+3325147568 33894
+4124728025 33894
diff --git a/test/pamditherbw.test b/test/pamditherbw.test
index fef71efa..1ac1391c 100755
--- a/test/pamditherbw.test
+++ b/test/pamditherbw.test
@@ -1,35 +1,34 @@
 #! /bin/bash
 # This script tests: pamditherbw
-# Also requires: ppmtopgm
+# Also requires: pamchannel
 
   alias pamditherbw="${PBM_TESTPREFIX}pamditherbw"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
-# Make test input
-ppmtopgm testimg.ppm >${tmpdir}/testimg.pgm
+tmpdir=${tmpdir:-/tmp}
+test_red=${tmpdir}/testimg.red
 
 # Test 1.  Simple threshold
-pamditherbw -threshold -val=0.5 \
-   ${tmpdir}/testimg.pgm | cksum
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  tee ${test_red} | \
+  pamditherbw -threshold -val=0.5 | cksum
 
 # Test 2.  Floyd-Steinberg
-#pamditherbw -floyd -val=0.5 ${tmpdir}/testimg.pgm | cksum
+#pamditherbw -floyd -val=0.5 ${test_red} | cksum
 
 # Test 3. Atkinson
-#pamditherbw -atkinson -val=0.5 ${tmpdir}/testimg.pgm | cksum
+#pamditherbw -atkinson -val=0.5 ${test_red} | cksum
 
 # Test 4. Hilbert
-pamditherbw -hilbert ${tmpdir}/testimg.pgm | cksum
+pamditherbw -hilbert ${test_red} | cksum
 
 # Test 5. Dither-8
-pamditherbw -dither8 ${tmpdir}/testimg.pgm | cksum
+pamditherbw -dither8 ${test_red} | cksum
 
 # Test 6. Cluster4
-pamditherbw -cluster4 ${tmpdir}/testimg.pgm | cksum
+pamditherbw -cluster4 ${test_red} | cksum
 
 # Test 7. Atkinson
-#pamditherbw -atkinson -val=0.5 ${tmpdir}/testimg.pgm | cksum
+#pamditherbw -atkinson -val=0.5 ${test_red} | cksum
 
-# Remove test file
-rm ${tmpdir}/testimg.pgm
+rm ${test_red}
diff --git a/test/pamenlarge.ok b/test/pamenlarge.ok
index 40be5918..055262c9 100644
--- a/test/pamenlarge.ok
+++ b/test/pamenlarge.ok
@@ -1,4 +1,4 @@
 3424505894 913236
-4152147096 304422
+3763267672 304422
 3342398172 297
 237488670 3133413
diff --git a/test/pamenlarge.test b/test/pamenlarge.test
index c1958d14..8f9e3c70 100755
--- a/test/pamenlarge.test
+++ b/test/pamenlarge.test
@@ -1,15 +1,15 @@
 #! /bin/bash
 # This script tests: pamenlarge
-# Also requires: ppmtopgm
+# Also requires: pamchannel
 
   alias pamenlarge="${PBM_TESTPREFIX}pamenlarge"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
 # Test 1.  Should print 3424505894 913236
 pamenlarge 3 testimg.ppm | cksum
-# Test 2.  Should print 4152147096 304422
-ppmtopgm testimg.ppm | pamenlarge 3 | cksum
+# Test 2.  Should print 3763267672 304422
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  pamenlarge 3 | cksum
 # Test 3.  Should print 3342398172 297
 pamenlarge 3 testgrid.pbm | cksum
 # Test 4.  Should print 237488670 3133413
diff --git a/test/pamfile.ok b/test/pamfile.ok
index 6cdf0433..57cc8cfd 100644
--- a/test/pamfile.ok
+++ b/test/pamfile.ok
@@ -1,3 +1,5 @@
 testimg.ppm:	PPM raw, 227 by 149  maxval 255
 testgrid.pbm:	PBM raw, 14 by 16
 stdin:	PGM raw, 227 by 149  maxval 255
+stdin:	PAM, 227 by 149 by 1 maxval 255
+    Tuple type: GRAYSCALE
diff --git a/test/pamfile.test b/test/pamfile.test
index 689578f1..1c1d3d23 100755
--- a/test/pamfile.test
+++ b/test/pamfile.test
@@ -1,11 +1,14 @@
 #! /bin/bash
 # This script tests: pamfile
-# Also requires: ppmtopgm
+# Also requires: pamchannel
 
   alias pamfile="${PBM_TESTPREFIX}pamfile"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
 pamfile testimg.ppm
 pamfile testgrid.pbm
-ppmtopgm testimg.ppm | pamfile
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | pamfile
+pamchannel -tupletype="GRAYSCALE" -infile=testimg.ppm 0 | pamfile
+
+
+
diff --git a/test/pamflip1.test b/test/pamflip1.test
index 0f60b72b..0f60b72b 100644..100755
--- a/test/pamflip1.test
+++ b/test/pamflip1.test
diff --git a/test/pamflip2.test b/test/pamflip2.test
index d9418b25..d9418b25 100644..100755
--- a/test/pamflip2.test
+++ b/test/pamflip2.test
diff --git a/test/pamslice-roundtrip.test b/test/pamslice-roundtrip.test
index edec0d26..f17765d1 100755
--- a/test/pamslice-roundtrip.test
+++ b/test/pamslice-roundtrip.test
@@ -30,14 +30,18 @@
 # Add header and reconstruct ppm image.
 # Should print 914327477 4864
 
-pamcut 50 50 49 33 testimg.ppm > ${tmpdir}/test4933.ppm
+tmpdir=${tmpdir:-/tmp}
+
+test4933_ppm=${tmpdir}/test4933.ppm
+
+pamcut 50 50 49 33 testimg.ppm > ${test4933_ppm}
 
 (echo "P3"
  echo "49 33"
  echo "255"
  seq 0 32 | while read i;
      do
-     pamslice -row=$i ${tmpdir}/test4933.ppm | awk '{print $2, $3, $4}';
+     pamslice -row=$i ${test4933_ppm} | awk '{print $2, $3, $4}';
      done ) | pnmtopnm | cksum
 
 # Same as above test 2, but take cols instead of rows.
@@ -48,25 +52,27 @@ pamcut 50 50 49 33 testimg.ppm > ${tmpdir}/test4933.ppm
  echo "255"
  seq 0 48 | while read i;
      do
-     pamslice -col=$i ${tmpdir}/test4933.ppm | awk '{print $2, $3, $4}';
+     pamslice -col=$i ${test4933_ppm} | awk '{print $2, $3, $4}';
      done ) | pamflip -xy | cksum
 
 # Test 4.
 # Divide input image into two with pamdeinterlace and recombine.
 
-pamdeinterlace -takeodd ${tmpdir}/test4933.ppm > ${tmpdir}/testodd.ppm
-pamdeinterlace -takeeven ${tmpdir}/test4933.ppm > ${tmpdir}/testevn.ppm
+testeven_ppm=${tmpdir}/testeven.ppm
+testodd_ppm=${tmpdir}/testodd.ppm
+
+pamdeinterlace -takeodd ${test4933_ppm} > ${testodd_ppm}
+pamdeinterlace -takeeven ${test4933_ppm} > ${testeven_ppm}
 
 (echo "P3"
  echo "49 33"
  echo "255"
  seq 0 15 | while read i;
      do
-     pamslice -row=$i ${tmpdir}/testevn.ppm | awk '{print $2, $3, $4}';
-     pamslice -row=$i ${tmpdir}/testodd.ppm | awk '{print $2, $3, $4}';
+     pamslice -row=$i ${testeven_ppm} | awk '{print $2, $3, $4}';
+     pamslice -row=$i ${testodd_ppm} | awk '{print $2, $3, $4}';
      done
-     pamslice -row=16 ${tmpdir}/testevn.ppm | awk '{print $2, $3, $4}';
+     pamslice -row=16 ${testeven_ppm} | awk '{print $2, $3, $4}';
   ) | pnmtopnm | tee /tmp/z | cksum
 
-rm ${tmpdir}/test4933.ppm ${tmpdir}/testodd.ppm ${tmpdir}/testevn.ppm
-
+rm ${test4933_ppm} ${testodd_ppm} ${testeven_ppm}
diff --git a/test/pbmclean.test b/test/pbmclean.test
index 28242d30..5f324c5e 100755
--- a/test/pbmclean.test
+++ b/test/pbmclean.test
@@ -8,15 +8,17 @@
   alias pnmmargin="${PBM_BINPREFIX}pnmmargin"
   shopt -s expand_aliases
 
-pbmmake -g 3 3 | pnmmargin -black 2 \
- >${tmpdir}/test.pbm
+tmpdir=${tmpdir:-/tmp}
+test_pbm=${tmpdir}/test.pbm
+
+pbmmake -g 3 3 | pnmmargin -black 2 > ${test_pbm}
 
 for n in 1 2 3 4 5 6 7 8
 do
-pbmclean -min=$n -black -plain ${tmpdir}/test.pbm
+pbmclean -min=$n -black -plain ${test_pbm}
 done
 
-rm ${tmpdir}/test.pbm
+rm ${test_pbm}
 
 # Should print 760076056 4210813
 pbmpage 1 | pbmclean -black | cksum
diff --git a/test/pcx-roundtrip.ok b/test/pcx-roundtrip.ok
new file mode 100644
index 00000000..968f46b9
--- /dev/null
+++ b/test/pcx-roundtrip.ok
@@ -0,0 +1,5 @@
+1926073387 101484
+369063776 101484
+369063776 101484
+369063776 101484
+829921912 685
diff --git a/test/pcx-roundtrip.test b/test/pcx-roundtrip.test
new file mode 100755
index 00000000..5efbbca9
--- /dev/null
+++ b/test/pcx-roundtrip.test
@@ -0,0 +1,49 @@
+# This script tests: ppmtopcx pcxtoppm
+# Also requires: pnmremap
+
+  alias ppmtopcx="${PBM_TESTPREFIX}ppmtopcx"
+  alias pcxtoppm="${PBM_TESTPREFIX}pcxtoppm"
+  alias ppmremap="${PBM_BINPREFIX}ppmremap"
+  shopt -s expand_aliases
+
+tmpdir=${tmpdir:-/tmp}
+pcxstd_ppm=${tmpdir}/pcxstd_ppm
+testpcx_ppm=${tmpdir}/test-pcx.ppm
+
+cat > ${pcxstd_ppm} << EOF
+P3
+16 1
+255
+  0   0   0
+  0   0 170
+  0 170   0
+  0 170 170
+170   0   0
+170   0 170
+170 170   0
+170 170 170
+ 85  85  85
+ 85  85 255
+ 85 255  85
+ 85 255 255
+255  85  85
+255  85 255
+255 255  85
+255 255 255
+EOF
+
+# Test 1. Should print 1926073387 101484
+ppmtopcx testimg.ppm | pcxtoppm | cksum
+
+# Test 2.  Should print 369063776 101484 three times
+pnmremap testimg.ppm -mapfile=${pcxstd_ppm} | tee ${testpcx_ppm} | cksum
+ppmtopcx -stdpalette -packed ${testpcx_ppm} | pcxtoppm | cksum
+ppmtopcx -stdpalette -packed -8bit ${testpcx_ppm} | pcxtoppm | cksum
+
+rm ${testpcx_ppm} ${pcxstd_ppm}
+
+# Test 3. Should print 829921912 685 which is the
+# result of:
+# pgmtoppm < testgrid.pbm | cksum
+ppmtopcx -stdpalette -packed testgrid.pbm | pcxtoppm | cksum
+
diff --git a/test/pgmbentley.ok b/test/pgmbentley.ok
new file mode 100644
index 00000000..2ae59958
--- /dev/null
+++ b/test/pgmbentley.ok
@@ -0,0 +1 @@
+4127286153 16399
diff --git a/test/pgmbentley.test b/test/pgmbentley.test
new file mode 100755
index 00000000..8af2c59c
--- /dev/null
+++ b/test/pgmbentley.test
@@ -0,0 +1,10 @@
+#! /bin/bash
+# This script tests: pgmbentley
+# Also requires: pgmramp
+
+  alias pgmbentley="${PBM_TESTPREFIX}pgmbentley"
+  alias pgmramp="${PBM_BINPREFIX}pgmramp"
+  shopt -s expand_aliases
+
+# Test. Should produce 4127286153 16399
+pgmramp -rect 128 128 | pgmbentley | cksum
diff --git a/test/pgmtoppm.test b/test/pgmtoppm.test
index cdd53623..f2d0fffb 100755
--- a/test/pgmtoppm.test
+++ b/test/pgmtoppm.test
@@ -8,17 +8,22 @@
   alias pgmramp="${PBM_BINPREFIX}pgmramp"
   shopt -s expand_aliases
 
-pgmramp -maxval=5 -lr 256 1 >${tmpdir}/test.pgm
+tmpdir=${tmpdir:-/tmp}
+
+test_pgm=${tmpdir}/test.pgm
+palette=${tmpdir}/palette
+
+pgmramp -maxval=5 -lr 256 1 >${test_pgm}
 pamseq 3 5 -tupletype=RGB | pamtopnm \
-  >${tmpdir}/palette
+  >${palette}
 
 # Test 1.
-pgmtoppm green ${tmpdir}/test.pgm | cksum
+pgmtoppm green ${test_pgm} | cksum
 
-pgmtoppm yellow-blue ${tmpdir}/test.pgm | cksum
+pgmtoppm yellow-blue ${test_pgm} | cksum
 
-pgmtoppm -map=${tmpdir}/palette ${tmpdir}/test.pgm | cksum
+pgmtoppm -map=${palette} ${test_pgm} | cksum
 
-rm ${tmpdir}/test.pgm ${tmpdir}/palette
+rm ${test_pgm} ${palette}
 
 
diff --git a/test/pi3-roundtrip.ok b/test/pi3-roundtrip.ok
new file mode 100644
index 00000000..3fde31b1
--- /dev/null
+++ b/test/pi3-roundtrip.ok
@@ -0,0 +1,2 @@
+3139449799 32011
+2425386270 41
diff --git a/test/pi3-roundtrip.test b/test/pi3-roundtrip.test
new file mode 100755
index 00000000..cd4232eb
--- /dev/null
+++ b/test/pi3-roundtrip.test
@@ -0,0 +1,22 @@
+# This script tests: pbmtopi3 pi3topbm
+# Also requires: pbmmake pamcut
+
+  alias pbmtopi3="${PBM_TESTPREFIX}pbmtopi3"
+  alias pi3topbm="${PBM_TESTPREFIX}pi3topbm"
+  alias pbmmake="${PBM_BINPREFIX}pbmmake"
+  alias pamcut="${PBM_BINPREFIX}pamcut"
+  shopt -s expand_aliases
+
+# The pi3 image format specifies a fixed image size of 640x400.
+# Pbmtopi3 rejects images that do not conform.
+
+# Test
+# Should print: 3139449799 32011
+pbmmake -g 640 400 | pbmtopi3 | pi3topbm | cksum
+
+# Test 2. 
+# Should print: 2425386270 41
+pamcut -pad 0 0 640 400 testgrid.pbm | \
+  pbmtopi3 | pi3topbm | pamcut 0 0 14 16 | cksum
+
+
diff --git a/test/pict-roundtrip.ok b/test/pict-roundtrip.ok
new file mode 100644
index 00000000..d50b54bc
--- /dev/null
+++ b/test/pict-roundtrip.ok
@@ -0,0 +1 @@
+984199586 101484
diff --git a/test/pict-roundtrip.test b/test/pict-roundtrip.test
new file mode 100755
index 00000000..457cb4b8
--- /dev/null
+++ b/test/pict-roundtrip.test
@@ -0,0 +1,15 @@
+#! /bin/bash
+# This script tests: picttoppm ppmtopict
+# Also requires: pamseq pamdepth pamtopnm pnmremap
+
+  alias picttoppm="${PBM_TESTPREFIX}picttoppm"
+  alias ppmtopict="${PBM_TESTPREFIX}ppmtopict"
+  alias pamseq="${PBM_BINPREFIX}pamseq"
+  alias pamdepth="${PBM_BINPREFIX}pamdepth"
+  alias pamtopnm="${PBM_BINPREFIX}pamtopnm"
+  alias pnmremap="${PBM_BINPREFIX}pnmremap"
+  shopt -s expand_aliases
+
+#Test.  Should print 984199586 101484
+pamseq 3 5 -tupletype=RGB | pamdepth 255 | pamtopnm | \
+  pnmremap -mapfile=- testimg.ppm | ppmtopict | picttoppm | cksum
diff --git a/test/pnminvert.ok b/test/pnminvert.ok
index 081e53ee..6cf5f011 100644
--- a/test/pnminvert.ok
+++ b/test/pnminvert.ok
@@ -1,6 +1,6 @@
 1240379484 41
 1416115901 101484
-2961441369 33838
+1174803406 33838
 2595564405 14
 2595564405 14
 2595564405 14
diff --git a/test/pnminvert.test b/test/pnminvert.test
index eb25d2a0..f779d574 100755
--- a/test/pnminvert.test
+++ b/test/pnminvert.test
@@ -1,25 +1,29 @@
 #! /bin/bash
 # This script tests: pnminvert
-# Also requires: pbmmake ppmtopgm
+# Also requires: pbmmake
 
   alias pnminvert="${PBM_TESTPREFIX}pnminvert"
   alias pbmmake="${PBM_BINPREFIX}pbmmake"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
 # Test 1.  Should print 1240379484 41
 pnminvert testgrid.pbm | cksum
+
 # Test 2.  Should print 1416115901 101484
 pnminvert testimg.ppm | cksum
-# Test 3.  Should print 2961441369 33838
-# printed 4215652354 33838 with older ppmtopgm
-ppmtopgm testimg.ppm | pnminvert | cksum
+
+# Test 3.  Should print 
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  pnminvert | cksum
+
 # Test 4.  Should print 2595564405 14
 pbmmake -w 7 7 | pnminvert | cksum
+
 # Test 5.  Should print 2595564405 14
 pbmmake -b 7 7 | cksum
+
 # Test 6.  Should print 2595564405 14
-pbmmake -b 7 7 | pnminvert | \
-  pnminvert | cksum
+pbmmake -b 7 7 | pnminvert | pnminvert | cksum
+
 # Test 7.  Should print 2896726098 15
 pbmmake -g 8 8 | pnminvert | cksum
diff --git a/test/pnmpsnr.test b/test/pnmpsnr.test
index da88d70d..db1f0079 100755
--- a/test/pnmpsnr.test
+++ b/test/pnmpsnr.test
@@ -6,10 +6,18 @@
   alias pbmmake="${PBM_BINPREFIX}pbmmake"
   shopt -s expand_aliases
 
-pbmmake -w 10 10 > ${tmpdir}/w.pbm
-pbmmake -b 10 10 > ${tmpdir}/b.pbm
-pnmpsnr  ${tmpdir}/w.pbm  ${tmpdir}/b.pbm 2>&1 | \
+tmpdir=${tmpdir:-/tmp}
+
+
+w_pbm=${tmpdir}/w.pbm
+b_pbm=${tmpdir}/b.pbm
+
+pbmmake -w 10 10 > ${w_pbm}
+pbmmake -b 10 10 > ${b_pbm}
+
+pnmpsnr  ${w_pbm}  ${b_pbm} 2>&1 | \
  awk '{print $(NF-1),$NF}'
-pnmpsnr  ${tmpdir}/w.pbm  ${tmpdir}/w.pbm 2>&1 | \
+pnmpsnr  ${w_pbm}  ${w_pbm} 2>&1 | \
  awk '{print $(NF-1),$NF}'
-rm ${tmpdir}/b.pbm ${tmpdir}/w.pbm
+
+rm ${b_pbm} ${w_pbm}
diff --git a/test/pnmremap1.test b/test/pnmremap1.test
index 208be2fb..20bee75d 100755
--- a/test/pnmremap1.test
+++ b/test/pnmremap1.test
@@ -8,9 +8,12 @@
   alias pamtopnm="${PBM_BINPREFIX}pamtopnm"
   shopt -s expand_aliases
 
-pamseq 3 5 -tupletype=RGB | pamtopnm \
- > ${tmpdir}/palette
-pamdepth 255 ${tmpdir}/palette > ${tmpdir}/palette255
+tmpdir=${tmpdir:-/tmp}
+palette=${tmpdir}/palette 
+#palette255=${tmpdir}/palette255
+
+pamseq 3 5 -tupletype=RGB | pamtopnm > ${palette}
+#pamdepth 255 ${palette} > ${palette255}
 
 # Test 1. Floyd-Steinberg
 # This fails with older versions of Netpbm and x86-64.
@@ -19,7 +22,10 @@ pamdepth 255 ${tmpdir}/palette > ${tmpdir}/palette255
 # x86-32: 2667816854 101482 
 # x86-64: 3602410851 101482
 
-pnmremap -mapfile=${tmpdir}/palette -floyd -norandom \
+pnmremap -mapfile=${palette} -floyd -norandom \
  testimg.ppm | cksum
 
-rm ${tmpdir}/palette{,255}
+#pnmremap -mapfile=${palette255} -floyd -norandom \
+# testimg.ppm | cksum
+
+rm ${palette} # ${palette255}
diff --git a/test/pnmremap2.test b/test/pnmremap2.test
index 3399dc39..e5444fda 100755
--- a/test/pnmremap2.test
+++ b/test/pnmremap2.test
@@ -8,20 +8,23 @@
   alias pamtopnm="${PBM_BINPREFIX}pamtopnm"
   shopt -s expand_aliases
 
-pamseq 3 5 -tupletype=RGB | pamtopnm \
- > ${tmpdir}/palette
-pamdepth 255 ${tmpdir}/palette > ${tmpdir}/palette255
+tmpdir=${tmpdir:-/tmp}
+palette=${tmpdir}/palette 
+palette255=${tmpdir}/palette255
+
+pamseq 3 5 -tupletype=RGB | pamtopnm > ${palette}
+pamdepth 255 ${palette} > ${palette255}
 
 # Test 2. Default (unmodified quantization)
-pnmremap -mapfile=${tmpdir}/palette -nofloyd \
+pnmremap -mapfile=${palette} -nofloyd \
 testimg.ppm | cksum
 
 # Test 3. Use first color in palette for missing colors
-pnmremap -mapfile=${tmpdir}/palette255 -nofloyd \
+pnmremap -mapfile=${palette255} -nofloyd \
  -firstisdefault testimg.ppm | cksum
 
 # Test 4. Use black for missing colors
-pnmremap -mapfile=${tmpdir}/palette255 -nofloyd \
+pnmremap -mapfile=${palette255} -nofloyd \
 -missingcolor=black testimg.ppm | cksum
 
-rm ${tmpdir}/palette{,255}
+rm ${palette} ${palette255}
diff --git a/test/pnmtile.test b/test/pnmtile.test
index f74bdce3..40d9cfc2 100755
--- a/test/pnmtile.test
+++ b/test/pnmtile.test
@@ -6,12 +6,20 @@
   alias pnmcat="${PBM_BINPREFIX}pnmcat"
   shopt -s expand_aliases
 
+# Test 1.  Should print 4228632379 259
 pnmtile 40 50 testgrid.pbm | cksum
 
-pnmtile 454 298 testimg.ppm > ${tmpdir}/testimg4.ppm &&
-pnmcat -lr testimg.ppm testimg.ppm > ${tmpdir}/testimg2.ppm &&
-pnmcat -tb ${tmpdir}/testimg2.ppm ${tmpdir}/testimg2.ppm | \
-cmp -s - ${tmpdir}/testimg4.ppm
+tmpdir=${tmpdir:-/tmp}
+
+# Test 2.  Compare 2x2 tile images produced by pnmtile and pnmcat
+# Should print 0
+testimg2_ppm=${tmpdir}/testimg2.ppm
+testimg4_ppm=${tmpdir}/testimg4.ppm
+
+pnmtile 454 298 testimg.ppm > ${testimg4_ppm} &&
+pnmcat -lr testimg.ppm testimg.ppm > ${testimg2_ppm} &&
+pnmcat -tb ${testimg2_ppm} ${testimg2_ppm} | \
+cmp -s - ${testimg4_ppm}
 echo $?
 
-rm ${tmpdir}/testimg{2,4}.ppm
+rm ${testimg2_ppm} ${testimg4_ppm}
diff --git a/test/ppmcie.test b/test/ppmcie.test
index c4338195..973787ec 100755
--- a/test/ppmcie.test
+++ b/test/ppmcie.test
@@ -7,6 +7,12 @@
   alias pamsumm="${PBM_BINPREFIX}pamsumm"
   shopt -s expand_aliases
 
+# Failure message
+## Ppmcie is sensitive to system factors.  If this test fails, please
+## run the program and visually examine the output.
+
+tmpdir=${tmpdir:-/tmp}
+
 # Test 1. Should print 955840041 786447
 # Without -nolabel -noaxes -nowpoint -noblack older versions of
 # Netpbm produce slightly different charts.
@@ -14,8 +20,10 @@
 # v. 10.35.86: 288356530 786447   
 # v. 10.59.2 : 2292601420 786447  
 
+ppmcie_ppm=${tmpdir}/ppmcie.ppm
+
 ppmcie -nolabel -noaxes -nowpoint -noblack \
- > ${tmpdir}/ppmcie.ppm
+ > ${ppmcie_ppm}
 
 # There is a slight difference in the output depending on whether ppmcie
 # is compiled with SSE features are turned on or off.
@@ -31,7 +39,7 @@ ppmcie -nolabel -noaxes -nowpoint -noblack \
 # x86 32 bit: 38.660173
 # x86 64 bit: 38.681432
 
-pamsumm --mean --brief ${tmpdir}/ppmcie.ppm | \
+pamsumm --mean --brief ${ppmcie_ppm} | \
   awk '{ if(38.65 < $1 && $1 <38.69) print "ok"; else print $1}'
 
 # Test 2.  Measure image sharpness
@@ -39,9 +47,9 @@ pamsumm --mean --brief ${tmpdir}/ppmcie.ppm | \
 # x86 32 bit: 0.002476
 # x86 64 bit: 0.002478
 
-pamsharpness ${tmpdir}/ppmcie.ppm 2>&1 | \
+pamsharpness ${ppmcie_ppm} 2>&1 | \
   awk 'NF==3 && $1=="Sharpness" \
        {if (0.002475 < $3 && $3 < 0.002479) print "ok"; else print $3}
        NF>0 && NF!=3 {print "error"}'
 
-rm ${tmpdir}/ppmcie.ppm
+rm ${ppmcie_ppm}
diff --git a/test/ppmdim.test b/test/ppmdim.test
index e528c3ce..cdd7df17 100755
--- a/test/ppmdim.test
+++ b/test/ppmdim.test
@@ -8,18 +8,23 @@
   alias pnmarith="${PBM_BINPREFIX}pnmarith"
   shopt -s expand_aliases
 
+tmpdir=${tmpdir:-/tmp}
+
 # Compare ppmdim and pamfunc with various dim factors
 # Due to the difference in rounding methods, pamfunc produces slightly
 # brighter images, by about 0.5 per pixel.
 # If the mean difference is between 0 and 0.75 we consider the output
 # normal.  This works for dim values up to 0.994 .
+dim1_ppm=${tmpdir}/dim1.ppm
+dim2_ppm=${tmpdir}/dim2.ppm
 
 for i in  0.125 0.25 0.5 0.75 0.1 0.0117 0.2 0.4 0.333 0.666 0.8 0.9 0.95
   do
-  ppmdim $i testimg.ppm > ${tmpdir}/dim1.ppm
-  pamfunc -mult=$i testimg.ppm > ${tmpdir}/dim2.ppm
-  pnmarith -diff ${tmpdir}/dim1.ppm ${tmpdir}/dim2.ppm | \
+  ppmdim $i testimg.ppm > ${dim1_ppm}
+  pamfunc -mult=$i testimg.ppm > ${dim2_ppm}
+  pnmarith -diff ${dim1_ppm} ${dim2_ppm} | \
     pamsumm -mean -brief | \
     awk '{print $1<0.75 ? "ok" : "fail"}'
   done
-rm ${tmpdir}/dim[12].ppm
+
+rm ${dim1_ppm} ${dim2_ppm}
diff --git a/test/ppmmix.test b/test/ppmmix.test
index d24e589d..25e35f0e 100755
--- a/test/ppmmix.test
+++ b/test/ppmmix.test
@@ -13,14 +13,19 @@
   alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
-# Print a pretty checkerboard pattern
+tmpdir=${tmpdir:-/tmp}
+
+# Test 1. Print a pretty checkerboard pattern
+a1_pgm=${tmpdir}/a1.pgm
+a2_pgm=${tmpdir}/a2.pgm
+
 pbmmake -g 8 8 | \
- pgmtopgm > ${tmpdir}/a1.pgm &&
+ pgmtopgm > ${a1_pgm} &&
 pbmmake -g 2 2 | pamenlarge 4 | \
- pgmtopgm > ${tmpdir}/a2.pgm &&
-ppmmix 0.75 ${tmpdir}/a1.pgm ${tmpdir}/a2.pgm -plain | \
+ pgmtopgm > ${a2_pgm} &&
+ppmmix 0.75 ${a1_pgm} ${a2_pgm} -plain | \
  ppmtopgm | pamdepth 3 -plain &&
-rm ${tmpdir}/a1.pgm ${tmpdir}/a2.pgm
+rm ${a1_pgm} ${a2_pgm}
 
 # Mix image with itself.
 # Output should match input regardless of ratio. 
@@ -31,8 +36,10 @@ done
 
 # Mix image with its own inverse.
 # Output should be a monotone gray sheet.
+a3_ppm=${tmpdir}/a3.ppm
+
 pnminvert testimg.ppm | ppmmix .5 \
-    testimg.ppm - | tee ${tmpdir}/a3.ppm | \
+    testimg.ppm - | tee ${a3_ppm} | \
   pamsumm -brief -max &&
-  pamsumm -brief -min ${tmpdir}/a3.ppm &&
-rm ${tmpdir}/a3.ppm
+  pamsumm -brief -min ${a3_ppm} &&
+rm ${a3_ppm}
diff --git a/test/ps-alt-roundtrip.test b/test/ps-alt-roundtrip.test
index 8c4cfc2a..d61e55d9 100755
--- a/test/ps-alt-roundtrip.test
+++ b/test/ps-alt-roundtrip.test
@@ -19,38 +19,49 @@
 #
 # pbmtopsg3 and pbmtolps produce output that require pstopnm for decoding.
 #
-# If ps-roundtrip.test succeeds and this test fails, it is most likely
-# a problem with one of the minor utilities, and vice versa.
+# Failure message
+## If ps-roundtrip.test succeeds and this test fails, it is most likely
+## a problem with one of the alternate Postscipt utilities:
+## pbmtoepsi, pbmtopsg3, pbmtolps or psidtopgm.
+## If both tests fail it indicates a problem with pstopnm or gs.
 
 # pstopnm does not use libnetpbm functions for output. 
 # Output is filtered through pnmtopnm.
 
 # Test 1. Should print: 2425386270 41
+testgrid1_ps=${tmpdir}/testgrid1.ps
+
 pbmtopsg3 -dpi=72 testgrid.pbm \
-     > ${tmpdir}/testgrid1.ps && \
+     > ${testgrid1_ps} && \
 pstopnm -xborder=0 -yborder=0 -llx=0 -lly=-16 -urx=14 \
-    -dpi=72 -stdout -quiet -pbm ${tmpdir}/testgrid1.ps | \
+    -dpi=72 -stdout -quiet -pbm ${testgrid1_ps} | \
     pnmcrop | cksum
 
+rm ${testgrid1_ps}
+
 
 # Test 2. Should print: 2425386270 41
+testgrid2_ps=${tmpdir}/testgrid2.ps
+
 pbmtolps -dpi 72 testgrid.pbm \
-     > ${tmpdir}/testgrid2.ps && \
+     > ${testgrid2_ps} && \
 pstopnm -xborder=0 -yborder=0 -dpi=72 -stdout \
-    -quiet ${tmpdir}/testgrid2.ps -pbm | \
+    -quiet ${testgrid2_ps} -pbm | \
   pnmcrop | cksum
 
+rm ${testgrid2_ps}
 
 # Test 3. Should print: 2916080186 235
 # Output is pgm maxval=1 with black and white inverted.
 #
-pbmtoepsi testgrid.pbm > ${tmpdir}/testgrid.epsi && \
+testgrid_epsi=${tmpdir}/testgrid.epsi 
+
+pbmtoepsi testgrid.pbm > ${testgrid_epsi} && \
 xysizebps=`awk  '/BeginPreview/ {print $2,$3,$4}' \
-    ${tmpdir}/testgrid.epsi` && \
+    ${testgrid_epsi}` && \
 awk '/^%%BeginPreview:/ { p=1; next } /^%%EndImage/ { p=0; next } \
   p==1 && /%[ \t0-9a-fA-F]+/ { print substr($0,2); next } \
   p==1 {print "!"$0}' \
-    ${tmpdir}/testgrid.epsi | psidtopgm $xysizebps | cksum
-
+    ${testgrid_epsi} | psidtopgm $xysizebps | cksum
 
-rm ${tmpdir}/testgrid[12].ps  ${tmpdir}/testgrid.epsi 
+rm ${testgrid_epsi} 
diff --git a/test/ps-roundtrip.test b/test/ps-roundtrip.test
index 1877724d..4773d4a6 100755
--- a/test/ps-roundtrip.test
+++ b/test/ps-roundtrip.test
@@ -16,46 +16,53 @@
 ## (1) zlib was not linked.
 ## (2) ghostscript is not available.
 
+tmpdir=${tmpdir:-/tmp}
+
 # pstopnm does not use libnetpbm functions for output. 
 # Output is filtered through pnmtopnm.
 
 # Test 1.  Should print: 1926073387 101484 five times
 # *NOTE* Fifth iteration fails if pnmtops was compiled without zlib
 # (flate compression) support.
+test1_ps=${tmpdir}/testimg1.ps
+
 for flag in "" "-ps" "-rle" "-ps -ascii" "-ps -flate"
   do
-  pnmtops -nocenter -equalpixels -dpi 72 -noturn \
-    ${flag} testimg.ppm \
-    > ${tmpdir}/testimg.ps
+  pnmtops -nocenter -equalpixels -dpi 72 -noturn ${flag} testimg.ppm \
+    > ${test1_ps} && \
   xysize1=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \
-    ${tmpdir}/testimg.ps` 
-  pstopnm -portrait -xborder=0 -yborder=0 $xysize1 -stdout \
-    -quiet ${tmpdir}/testimg.ps | \
-    pnmtopnm | cksum
+    ${test1_ps}` && \
+  pstopnm -portrait -xborder=0 -yborder=0 $xysize1 -stdout -quiet \
+    ${test1_ps} | pnmtopnm | cksum
   done
 
-
+rm ${test1_ps}
 # Test 2.  Should print: 2918318199 62 seven times
 # Test image designed to detect problems with run-length compression
 #
-pbmmake -g 2 2 > ${tmpdir}/g.pbm
+
+g_pbm=${tmpdir}/g.pbm
+t_pbm=${tmpdir}/t.pbm
+grid_ps=${tmpdir}/testgrid.ps
+
+pbmmake -g 2 2 > ${g_pbm}
 pbmmake -g 8 4 | \
   pnmshear 45 -noantialias -background=black | \
   pnmpad -right 60 | \
-  pnmcat -tb -jright - ${tmpdir}/g.pbm > ${tmpdir}/t.pbm &&
+  pnmcat -tb -jright - ${g_pbm} > ${t_pbm} &&
 for flag in "" "-rle" "-ps -rle -ascii" \
             "-bitspersample=2 -rle" "-ps -bitspersample=4 -rle" \
             "-bitspersample=8 -rle" "-ps -bitspersample=12 -rle -dict" 
   do
-  pnmtops -nocenter -equalpixels -dpi 72 -noturn \
-    ${flag} ${tmpdir}/t.pbm  > ${tmpdir}/testgrid.ps &&
+  pnmtops -nocenter -equalpixels -dpi 72 -noturn  ${flag} ${t_pbm} \
+    > ${grid_ps} && \
   xysize2=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \
-    ${tmpdir}/testgrid.ps`
+      ${grid_ps}` && \
   pstopnm -portrait -xborder=0 -yborder=0 $xysize2 -stdout \
-    -quiet ${tmpdir}/testgrid.ps -pbm | \
-    pnmtopnm | cksum
+    -quiet ${grid_ps} -pbm | pnmtopnm | cksum
   done
 
+rm ${grid_ps} ${g_pbm} ${t_pbm}
 
 #Test 3. Should print: 1386192571 507420 three times
 # *NOTE* Second iteration fails if pnmtops was compiled without zlib
@@ -69,19 +76,19 @@ for flag in "" "-rle" "-ps -rle -ascii" \
 # (3) pstopnm: input must be an ordinary file.  Input from stdin
 #     (by pipe or input redirection: "< file" ) does not work.              
 #
+
+test3_ps=${tmpdir}/testimg3.ps
+
 for flag in "" "-ps" \
             "-ps -bitspersample=12 -flate -rle -vmreclaim"
   do
 cat testimg.ppm testimg.ppm testimg.ppm testgrid.pbm testgrid.pbm | \
-pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage \
-  ${flag}  > ${tmpdir}/testimg5.ps
+pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage ${flag} \
+  > ${test3_ps} &&
 xysize3=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5 ; exit}' \
-  ${tmpdir}/testimg5.ps`
-pstopnm -portrait -xborder=0 -yborder=0 $xysize3 \
-    -stdout  ${tmpdir}/testimg5.ps | \
+  ${test3_ps}` &&
+pstopnm -portrait -xborder=0 -yborder=0 $xysize3 -stdout  ${test3_ps} | \
   pnmtopnm | cksum
   done
 
-
-rm ${tmpdir}/testgrid.ps  ${tmpdir}/testimg.ps  ${tmpdir}/testimg5.ps \
-   ${tmpdir}/t.pbm
+rm ${test3_ps}
diff --git a/test/rgb3-roundtrip.test b/test/rgb3-roundtrip.test
index 829feab4..091fe46b 100755
--- a/test/rgb3-roundtrip.test
+++ b/test/rgb3-roundtrip.test
@@ -13,29 +13,40 @@
 # image from them and check whether the resulting output is
 # identical to the original input.
 
+tmpdir=${tmpdir:-/tmp}
+
+# Test 1.  PPM (color) input
+testimg_ppm=${tmpdir}/testimg.ppm
+testimg_red=${tmpdir}/testimg.red
+testimg_grn=${tmpdir}/testimg.grn
+testimg_blu=${tmpdir}/testimg.blu
+
 cp testimg.ppm ${tmpdir} &&
-ppmtorgb3 ${tmpdir}/testimg.ppm &&
-rgb3toppm ${tmpdir}/testimg.red ${tmpdir}/testimg.grn \
-  ${tmpdir}/testimg.blu | cksum
+ppmtorgb3 ${testimg_ppm} &&
+rgb3toppm ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum
 
-cat ${tmpdir}/testimg.red ${tmpdir}/testimg.grn ${tmpdir}/testimg.blu | \
-  cksum
+cat ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum
 
-rm ${tmpdir}/testimg.{ppm,red,grn,blu}
+rm ${testimg_ppm} ${testimg_red} ${testimg_grn} ${testimg_blu}
+
+# Test 2.  PBM (monochrome) input
+testgrid_pbm=${tmpdir}/testgrid.pbm
+testgrid_red=${tmpdir}/testgrid.red
+testgrid_grn=${tmpdir}/testgrid.grn
+testgrid_blu=${tmpdir}/testgrid.blu
 
 cp testgrid.pbm ${tmpdir} &&
-ppmtorgb3 ${tmpdir}/testgrid.pbm &&
-rgb3toppm ${tmpdir}/testgrid.red ${tmpdir}/testgrid.grn \
-  ${tmpdir}/testgrid.blu | \
+ppmtorgb3 ${testgrid_pbm} &&
+rgb3toppm ${testgrid_red} ${testgrid_grn} ${testgrid_blu} | \
   ppmtopgm | pgmtopbm -th -val=0.5 | cksum
 
-
+# Test 3.
 # With PGM or PBM input, the three monochrome planes should be
 # identical.  Test for this.
 
-cmp -s ${tmpdir}/testgrid.red ${tmpdir}/testgrid.grn ; echo $?
-cmp -s ${tmpdir}/testgrid.grn ${tmpdir}/testgrid.blu ; echo $?
-pgmtopgm < testgrid.pbm | cmp -s - ${tmpdir}/testgrid.red
+cmp -s ${testgrid_red} ${testgrid_grn} ; echo $?
+cmp -s ${testgrid_grn} ${testgrid_blu} ; echo $?
+pgmtopgm < testgrid.pbm | cmp -s - ${testgrid_red}
   echo $?
 
-rm ${tmpdir}/testgrid.{pbm,red,grn,blu}
+rm ${testgrid_pbm} ${testgrid_red} ${testgrid_grn} ${testgrid_blu}
diff --git a/test/sgi-roundtrip.ok b/test/sgi-roundtrip.ok
new file mode 100644
index 00000000..541d59b1
--- /dev/null
+++ b/test/sgi-roundtrip.ok
@@ -0,0 +1,6 @@
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+538848130 235
+538848130 235
diff --git a/test/sgi-roundtrip.test b/test/sgi-roundtrip.test
new file mode 100755
index 00000000..99b5735e
--- /dev/null
+++ b/test/sgi-roundtrip.test
@@ -0,0 +1,38 @@
+#! /bin/bash
+# This script tests: pnmtosgi sgitopnm
+# Also requires: rgb3toppm
+
+  alias pnmtosgi="${PBM_TESTPREFIX}pnmtosgi"
+  alias sgitopnm="${PBM_TESTPREFIX}sgitopnm"
+  alias rgb3toppm="${PBM_BINPREFIX}rgb3toppm"
+  shopt -s expand_aliases
+
+a_sgi=${tmpdir}/a.sgi
+a_red=${tmpdir}/a.red
+a_grn=${tmpdir}/a.grn
+a_blu=${tmpdir}/a.blu
+
+# Test 1.  Should produce 1926073387 101484 twice
+pnmtosgi -rle testimg.ppm | tee ${a_sgi} | sgitopnm  | cksum
+sgitopnm -channel=0  ${a_sgi} > ${a_red}
+sgitopnm -channel=1  ${a_sgi} > ${a_grn}
+sgitopnm -channel=2  ${a_sgi} > ${a_blu}
+rgb3toppm ${a_red} ${a_grn} ${a_blu} | cksum
+rm ${a_sgi} ${a_red} ${a_grn} ${a_blu}
+
+b_sgi=${tmpdir}/b.sgi
+b_red=${tmpdir}/b.red
+b_grn=${tmpdir}/b.grn
+b_blu=${tmpdir}/b.blu
+
+# Test 2.  Should produce 1926073387 101484 twice
+pnmtosgi -verbatim testimg.ppm | tee ${b_sgi} | sgitopnm  | cksum
+sgitopnm -channel=0  ${b_sgi} > ${b_red}
+sgitopnm -channel=1  ${b_sgi} > ${b_grn}
+sgitopnm -channel=2  ${b_sgi} > ${b_blu}
+rgb3toppm ${b_red} ${b_grn} ${b_blu} | cksum
+rm ${b_sgi} ${b_red} ${b_grn} ${b_blu}
+
+# Test 3.  Should produce 2425386270 41 twice
+pnmtosgi testgrid.pbm | sgitopnm | cksum             # Defaults to -rle
+pnmtosgi -verbatim testgrid.pbm | sgitopnm | cksum
diff --git a/test/targa-roundtrip.ok b/test/targa-roundtrip.ok
index 2b4b6eb9..9a428195 100644
--- a/test/targa-roundtrip.ok
+++ b/test/targa-roundtrip.ok
@@ -1,3 +1,3 @@
 2425386270 41
-2871603838 33838
+1571496937 33838
 1926073387 101484
diff --git a/test/targa-roundtrip.test b/test/targa-roundtrip.test
index 4a99e0e0..66e666c6 100755
--- a/test/targa-roundtrip.test
+++ b/test/targa-roundtrip.test
@@ -1,11 +1,10 @@
 #! /bin/bash
 # This script tests: pamtotga tgatoppm
-# Also requires: ppmtopgm pgmtopbm
+# Also requires: pgmtopbm
 
   alias pamtotga="${PBM_TESTPREFIX}pamtotga"
   alias tgatoppm="${PBM_TESTPREFIX}tgatoppm"
   alias pgmtopbm="${PBM_BINPREFIX}pgmtopbm"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
 #Test 1: Should print 2425386270 41, cksum of testgrid.pbm
@@ -14,13 +13,9 @@ pamtotga -mono testgrid.pbm | \
   tgatoppm | ppmtopgm | \
   pgmtopbm -threshold -val 0.5 | cksum
 
-#Test 2: Should print 2871603838 33838, cksum of testimg.pgm
-
-ppmtopgm testimg.ppm > ${tmpdir}/testimg.pgm
-pamtotga -cmap ${tmpdir}/testimg.pgm | \
-  tgatoppm | ppmtopgm | cksum
-
-rm ${tmpdir}/testimg.pgm
+#Test 2:  Should produce 1571496937 33838, cksum of testimg.red
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | \
+  pamtotga -cmap | tgatoppm | ppmtopgm | cksum
 
 #Test 3: Should print 1926073387 101484, cksum of testimg.ppm
 
diff --git a/test/utahrle-roundtrip.ok b/test/utahrle-roundtrip.ok
index 35fc434c..203001aa 100644
--- a/test/utahrle-roundtrip.ok
+++ b/test/utahrle-roundtrip.ok
@@ -1,2 +1,2 @@
-2871603838 33838
+1571496937 33838
 1926073387 101484
diff --git a/test/utahrle-roundtrip.test b/test/utahrle-roundtrip.test
index 83bc6c90..dd88265c 100755
--- a/test/utahrle-roundtrip.test
+++ b/test/utahrle-roundtrip.test
@@ -1,18 +1,14 @@
 #! /bin/bash
 # This script tests: pnmtorle rletopnm
-# Also requires: ppmtopgm
+# Also requires: 
 
   alias pnmtorle="${PBM_TESTPREFIX}pnmtorle"
   alias rletopnm="${PBM_TESTPREFIX}rletopnm"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
-#Test 1.  Should print 2871603838 33838, cksum of testimg.pgm
-ppmtopgm testimg.ppm > ${tmpdir}/testimg.pgm
-pnmtorle ${tmpdir}/testimg.pgm | \
-  rletopnm | cksum
-
-rm ${tmpdir}/testimg.pgm
+#Test 1.  Should produce 1571496937 33838, cksum of testimg.red
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  pnmtorle | rletopnm | cksum
 
 #Test 2.  Should print 1926073387 101484, cksum of testimg.ppm
 pnmtorle testimg.ppm | \
diff --git a/test/xwd-roundtrip.ok b/test/xwd-roundtrip.ok
index 011ebd3a..25d3d871 100644
--- a/test/xwd-roundtrip.ok
+++ b/test/xwd-roundtrip.ok
@@ -1,3 +1,3 @@
-2871603838 33838
+1571496937 33838
 1926073387 101484
 2425386270 41
diff --git a/test/xwd-roundtrip.test b/test/xwd-roundtrip.test
index b5614f01..4dbd3020 100755
--- a/test/xwd-roundtrip.test
+++ b/test/xwd-roundtrip.test
@@ -1,17 +1,15 @@
 #! /bin/bash
 # This script tests: pnmtoxwd xwdtopnm
-# Also requires: pamdepth ppmtopgm
+# Also requires: pamdepth 
 
   alias pnmtoxwd="${PBM_TESTPREFIX}pnmtoxwd"
   alias xwdtopnm="${PBM_TESTPREFIX}xwdtopnm"
   alias pamdepth="${PBM_BINPREFIX}pamdepth"
-  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
   shopt -s expand_aliases
 
-# Test 1.  Should produce 2871603838 33838
-# which is the output of ppmtopgm testimg.ppm | cksum
-ppmtopgm testimg.ppm | pnmtoxwd  | \
-  xwdtopnm | pamdepth 255 | cksum
+# Test 1.  Should produce 1571496937 33838, cksum of testimg.red
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  pnmtoxwd | xwdtopnm | pamdepth 255 | cksum
 
 # Test 2.  Should produce 1926073387 101484
 pnmtoxwd --quiet  testimg.ppm | \