about summary refs log tree commit diff
path: root/test/rgb3-roundtrip.test
blob: 42fd822f50c959c4676ba87898c14e5f493525bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /bin/bash
# This script tests: ppmtorgb3 rgb3toppm
# Also requires: pgmtopbm pgmtopgm ppmtopgm


# Break an image into three monochrome planes, reassemble the
# 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 ${testimg_ppm} &&
rgb3toppm ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum

cat ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum

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 ${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 ${testgrid_red} ${testgrid_grn} ; echo $?
cmp -s ${testgrid_grn} ${testgrid_blu} ; echo $?
pgmtopgm < testgrid.pbm | cmp -s - ${testgrid_red}
  echo ${PIPESTATUS[@]} ":" $?

rm ${testgrid_pbm} ${testgrid_red} ${testgrid_grn} ${testgrid_blu}