about summary refs log tree commit diff
path: root/test/pnmcrop1.test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-06-28 23:54:29 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-06-28 23:54:29 +0000
commitbe0a23cddaf0182d1fda4f623a3b23f67db91d73 (patch)
tree5d46db6bd85005728f7821965e66e3e5f0018d62 /test/pnmcrop1.test
parentb13ba8b9b606c916e0bda39348ee009e920df22e (diff)
downloadnetpbm-mirror-be0a23cddaf0182d1fda4f623a3b23f67db91d73.tar.gz
netpbm-mirror-be0a23cddaf0182d1fda4f623a3b23f67db91d73.tar.xz
netpbm-mirror-be0a23cddaf0182d1fda4f623a3b23f67db91d73.zip
Promote Development to Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3647 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pnmcrop1.test')
-rwxr-xr-xtest/pnmcrop1.test75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/pnmcrop1.test b/test/pnmcrop1.test
new file mode 100755
index 00000000..6b37da23
--- /dev/null
+++ b/test/pnmcrop1.test
@@ -0,0 +1,75 @@
+#! /bin/bash
+# This script tests: pnmcrop
+# Also requires: pnmpad pnmmargin pamcut
+
+tmpdir=${tmpdir:-/tmp}
+
+test_pbm=${tmpdir}/test.pbm
+test_ppm=${tmpdir}/test.ppm
+
+pnmmargin -white 7 testgrid.pbm | pnmpad -black -bottom=2  > ${test_pbm}
+pnmmargin -white 6 testimg.ppm  | pnmpad -black -right=11  > ${test_ppm}
+
+#Test 1
+echo Test 1
+
+for input_file in ${test_pbm} ${test_ppm}
+  do
+  echo `basename ${input_file}`
+  for option in "" "-white" "-black" "-sides" \
+              "-top" "-bottom" "-left" "-right" "-top -bottom" \
+              "-bottom -bg-corner=bottomright" \
+              "-right -bg-corner=bottomright" \
+              "-bg-color=white" "-bg-color=black" "-bg-color=red"
+    do
+    echo ${option}
+    pnmcrop -reportfull ${option} ${input_file} || echo fail
+    done
+  done
+
+#Test 2
+echo Test 2
+
+for input_file in ${test_pbm} ${test_ppm}
+  do
+  echo `basename ${input_file}`
+  for option in "" "-white" "-top"
+    do
+    echo ${option}
+    # Normal crop operation
+    pnmcrop ${option} ${input_file} | cksum
+
+    # Compute edge extents with pnmcrop; let pamcut do the actual cropping
+    pamcut ${input_file} `pnmcrop -reportsize ${option} ${input_file} | \
+        awk 'NF==6 && NR==1 && \
+             $1<=0 && $2<=0 && $3<=0 && $4<=0 && $5>=0 && $6>=0 \
+             { printf("-cropleft=%d -cropright=%d  ", -$1, -$2);
+               printf("-croptop=%d -cropbottom=%d", -$3, -$4) }' ` | cksum
+    done
+  done
+
+rm ${test_pbm} ${test_ppm}
+
+# Test 3
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+echo Test 3
+for option in "-reportfull -reportsize" \
+              "-reportfull -borderfile=testgrid.pbm" \
+              "-reportsize -borderfile=testgrid.pbm" \
+              "-black -white" \
+              "-black -sides" \
+              "-white -bg-color=red" \
+              "-white -bg-corner=topleft" \
+              "-white -bg-corner=top" \
+              "-blank-image=pasturize" \
+              "-bg-color=black -closeness=-1" \
+              "-bg-color=black -closeness=101"
+    do
+    echo ${option}
+    pnmcrop -reportfull ${option} testgrid.pbm || echo expected failure
+    done