about summary refs log tree commit diff
path: root/test/tiff-roundtrip.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/tiff-roundtrip.test')
-rwxr-xr-xtest/tiff-roundtrip.test104
1 files changed, 90 insertions, 14 deletions
diff --git a/test/tiff-roundtrip.test b/test/tiff-roundtrip.test
index a99425fa..55aba278 100755
--- a/test/tiff-roundtrip.test
+++ b/test/tiff-roundtrip.test
@@ -1,23 +1,99 @@
 #! /bin/bash
 # This script tests: pamtotiff tifftopnm
-# Also requires:
-
+# Also requires: ppmpat pampick ppmtopgm
 
 # Failure message
-## Second test fails if Netpbm was built without the flate library
+## If this test fails, the cause may be a problem in the TIFF library.
+
+tmpdir=${tmpdir:-/tmp}
+tartan_ppm=${tmpdir}/tartan.ppm
+gingham_ppm=${tmpdir}/gingham.ppm
+argylecolor_ppm=${tmpdir}/argyle1.ppm
+argylegray_ppm=${tmpdir}/argyle2.ppm
+multiimage_tiff=${tmpdir}/multiimage.ppm
+
+# PPM image
+# Should print 1926073387 101484 five times
+
+echo PPM-rose
+pamtotiff testimg.ppm | tifftopnm -headerdump | cksum
+pamtotiff -truecolor testimg.ppm -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} -byrow | cksum
+pamtotiff -truecolor -packbits testimg.ppm | tifftopnm | cksum
+pamtotiff -truecolor -rowsperstrip=2 testimg.ppm | tifftopnm | cksum
+pamtotiff -truecolor -lsb2msb  testimg.ppm | \
+  tifftopnm -respectfillorder | cksum
+
+# PPM image with six colors
+# Should print 1646869394 29498 four times
+
+echo PPM-6
+ppmpat -tartan -color=rgb:0/8/8,rgb:8/f/8,rgb:f/f/0 108 91 | \
+  tee ${tartan_ppm} | cksum
+pamtotiff -truecolor ${tartan_ppm} | tifftopnm | cksum
+pamtotiff ${tartan_ppm} | tifftopnm -respectfillorder | cksum
+pamtotiff ${tartan_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 1 | cksum
+
+
+# PPM image with two colors
+# Should print 3743909631 14836 four times
+
+echo PPM-2
+ppmpat -argyle2 -color=rgb:0/0/0,rgb:f/8/f,rgb:0/0/0 61 81 | \
+  tee ${argylecolor_ppm} | cksum
+pamtotiff -indexbits=2 ${argylecolor_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 2 | cksum
+pamtotiff -indexbits=1 ${argylecolor_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1 -g4 ${argylecolor_ppm} | tifftopnm | cksum
+
+# PPM image with six shades of gray
+# pamtotiff detects the absence of colors and produces a grayscale
+# tiff image unless -color is specified
+# Pipeline output is PGM unless -color is specified
+# Should print 603974118 4954 six times
+
+echo PPM-gray
+ppmpat -gingham3 -color=rgb:0/0/0,rgb:ff/ff/ff,rgb:0/0/0 61 81 | \
+  tee ${gingham_ppm} | ppmtopgm | cksum
+pamtotiff -color ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1,2 -mb -fill ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1,2 -mw ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1,2,4,8 -mb ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -mb ${gingham_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 3 | cksum
+
+# PPM image with two shades of gray (bilevel)
+# pamtotiff detects the absence of colors and produces a grayscale
+# tiff image unless -color is specified
+# Pipeline output is PGM unless -color is specified
+# Should print 1001018459 4954 four times
+
+echo PPM-bilevel-black-white
+ppmpat -argyle2 -color=rgb:0/0/0,rgb:ff/ff/ff,rgb:0/0/0 61 81 | \
+  tee ${argylegray_ppm} | ppmtopgm | cksum
+pamtotiff -color -fill ${argylegray_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1 -mw ${argylegray_ppm} | tifftopnm | cksum
+pamtotiff -mb ${argylegray_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 4 | cksum
 
-pamtotiff testimg.ppm 1<>${tmpdir}/test1.tiff &&
-  tifftopnm ${tmpdir}/test1.tiff | cksum
+# PBM image
+# Should print 2425386270 41 three times
 
-# test flate compression
-pamtotiff -flate testimg.ppm 1<>${tmpdir}/test2.tiff &&
-  tifftopnm ${tmpdir}/test2.tiff | cksum
+echo PBM
+pamtotiff testgrid.pbm | tifftopnm | cksum
+pamtotiff -g3 -fill testgrid.pbm | tifftopnm | cksum
+pamtotiff -g4 -mb testgrid.pbm -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 5 | cksum
 
-pamtotiff testgrid.pbm 1<>${tmpdir}/test3.tiff &&
-  tifftopnm ${tmpdir}/test3.tiff | cksum
+# Extract individual images from multi-image tiff file
 
-# test G4 compression
-pamtotiff -g4 testgrid.pbm 1<>${tmpdir}/test4.tiff &&
-  tifftopnm ${tmpdir}/test4.tiff | cksum
+echo "Extract from multi-image TIFF"
+tifftopnm ${multiimage_tiff} | pampick 0 | cksum
+tifftopnm ${multiimage_tiff} | pampick 1 | cksum
+tifftopnm ${multiimage_tiff} | pampick 2 | cksum
+tifftopnm ${multiimage_tiff} | pampick 3 | cksum
+tifftopnm ${multiimage_tiff} | pampick 4 | cksum
 
-rm ${tmpdir}/test[1234].tiff
+rm ${tartan_ppm} ${gingham_ppm} ${argylecolor_ppm} \
+   ${argylegray_ppm} ${multiimage_tiff}
\ No newline at end of file