about summary refs log tree commit diff
path: root/test/gif-roundtrip.test
blob: a32d574a22a5b5ca382b896d3b7bef5b70913f1d (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
#! /bin/bash
# This script tests: giftopnm pamtogif
# Also requires: ppmtopgm ppmtorgb3 rgb3toppm pbmmake

# Test 1. Should produce 2871603838 33838
# which is the result of ppmtopgm testimg.ppm | cksum

${PBM_BINPREFIX}ppmtopgm testimg.ppm | \
  ${PBM_TESTPREFIX}pamtogif | ${PBM_TESTPREFIX}giftopnm | cksum

# Test 2. 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

cp testimg.ppm ${tmpdir} &&
${PBM_BINPREFIX}ppmtorgb3 ${tmpdir}/testimg.ppm &&
${PBM_TESTPREFIX}pamtogif ${tmpdir}/testimg.red | \
  ${PBM_TESTPREFIX}giftopnm > ${tmpdir}/out.red &&
${PBM_TESTPREFIX}pamtogif ${tmpdir}/testimg.grn |
  ${PBM_TESTPREFIX}giftopnm > ${tmpdir}/out.grn &&
${PBM_TESTPREFIX}pamtogif ${tmpdir}/testimg.blu | \
  ${PBM_TESTPREFIX}giftopnm | \
  ${PBM_BINPREFIX}rgb3toppm ${tmpdir}/testimg.red ${tmpdir}/testimg.grn - | \
  cksum

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

# Test 3. Should produce 2425386270 41
${PBM_TESTPREFIX}pamtogif testgrid.pbm | ${PBM_TESTPREFIX}giftopnm | cksum

# Test 4.
# In this gif file the code length changes after the last image data.
# Image data: 3 bits, end code 4 bits.
# Should produce P1 4 1 0 1 0 1

${PBM_BINPREFIX}pbmmake -g 4 1 | \
  ${PBM_TESTPREFIX}pamtogif | ${PBM_TESTPREFIX}giftopnm -plain | \
  tr '\n' ' '