about summary refs log tree commit diff
path: root/test/gif-roundtrip.test
blob: 574638ac1e80693c4e388a8020922884df13953e (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/bash
# This script tests: giftopnm pamtogif
# Also requires: ppmtopgm ppmtorgb3 rgb3toppm pbmmake

  alias giftopnm="${PBM_TESTPREFIX}giftopnm"
  alias pamtogif="${PBM_TESTPREFIX}pamtogif"
  alias pbmmake="${PBM_BINPREFIX}pbmmake"
  alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm"
  alias ppmtorgb3="${PBM_BINPREFIX}ppmtorgb3"
  alias rgb3toppm="${PBM_BINPREFIX}rgb3toppm"
  alias pnminvert="${PBM_BINPREFIX}pnminvert"
  shopt -s expand_aliases

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

ppmtopgm testimg.ppm | tee ${tmpdir}/testimg.pgm | pamtogif | giftopnm | cksum
pamtogif -interlace ${tmpdir}/testimg.pgm | giftopnm | cksum
pamtogif -sort ${tmpdir}/testimg.pgm | tee ${tmpdir}/testimg.gif | \
  giftopnm | cksum
echo "junk" >> ${tmpdir}/testimg.gif && \
  giftopnm -image=1 -quitearly ${tmpdir}/testimg.gif | cksum

rm  ${tmpdir}/testimg.pgm
rm  ${tmpdir}/testimg.gif

# 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} &&
ppmtorgb3 ${tmpdir}/testimg.ppm &&
pamtogif ${tmpdir}/testimg.red | \
  giftopnm > ${tmpdir}/out.red &&
pamtogif ${tmpdir}/testimg.grn |
  giftopnm > ${tmpdir}/out.grn &&
pamtogif ${tmpdir}/testimg.blu | \
  giftopnm | \
  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 five times.

pamtogif testgrid.pbm | giftopnm | cksum
pamtogif -nolzw testgrid.pbm | giftopnm | cksum
pamtogif -transparent=black testgrid.pbm | giftopnm | cksum
pamtogif -alpha=testgrid.pbm testgrid.pbm | giftopnm | cksum
pamtogif -transparent=white testgrid.pbm | giftopnm -alpha=- | \
  pnminvert | 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

pbmmake -g 4 1 | \
  pamtogif | giftopnm -plain | \
  tr '\n' ' '