about summary refs log tree commit diff
path: root/test/rgb3-roundtrip.test
blob: 829feab4538e3bfb6a7e5a2d9803f225baa65c75 (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
#! /bin/bash
# This script tests: ppmtorgb3 rgb3toppm
# Also requires: pgmtopbm pgmtopgm ppmtopgm

  alias ppmtorgb3="${PBM_TESTPREFIX}ppmtorgb3"
  alias rgb3toppm="${PBM_TESTPREFIX}rgb3toppm"
  alias pgmtopbm="${PBM_BINPREFIX}pgmtopbm"
  alias pgmtopgm="${PBM_BINPREFIX}pgmtopgm"
  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
  shopt -s expand_aliases

# Break an image into three monochrome planes, reassemble the
# image from them and check whether the resulting output is
# identical to the original input.

cp testimg.ppm ${tmpdir} &&
ppmtorgb3 ${tmpdir}/testimg.ppm &&
rgb3toppm ${tmpdir}/testimg.red ${tmpdir}/testimg.grn \
  ${tmpdir}/testimg.blu | cksum

cat ${tmpdir}/testimg.red ${tmpdir}/testimg.grn ${tmpdir}/testimg.blu | \
  cksum

rm ${tmpdir}/testimg.{ppm,red,grn,blu}

cp testgrid.pbm ${tmpdir} &&
ppmtorgb3 ${tmpdir}/testgrid.pbm &&
rgb3toppm ${tmpdir}/testgrid.red ${tmpdir}/testgrid.grn \
  ${tmpdir}/testgrid.blu | \
  ppmtopgm | pgmtopbm -th -val=0.5 | cksum


# 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
  echo $?

rm ${tmpdir}/testgrid.{pbm,red,grn,blu}