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


tmpdir=${tmpdir:-/tmp}

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

test_ppm=${tmpdir}/testimg.ppm

cp testimg.ppm ${tmpdir} &&
ppmtorgb3 ${test_ppm}

test_red=${tmpdir}/testimg.red
test_grn=${tmpdir}/testimg.grn
test_blu=${tmpdir}/testimg.blu
out_red=${tmpdir}/out.red
out_grn=${tmpdir}/out.grn
#out_blu=${tmpdir}/out.blu

pamtogif ${test_red} | giftopnm > ${out_red} &&
pamtogif ${test_grn} | giftopnm > ${out_grn} &&
pamtogif ${test_blu} | giftopnm | \
  rgb3toppm ${out_red} ${out_grn} - | \
  cksum

rm ${test_ppm} ${test_grn} ${test_blu} ${out_red} ${out_grn}


# Test 2. Should produce 1571496937 33838
# which is the result of cksum testimg.red
# four times

test_gif=${tmpdir}/testimg.gif

pamtogif ${test_red} | giftopnm | cksum
pamtogif -interlace ${test_red} | giftopnm | cksum
pamtogif -sort ${test_red} | tee ${test_gif} | \
  giftopnm | cksum
echo "junk" >> ${test_gif} && \
  giftopnm -image=1 -quitearly ${test_gif} | cksum

rm  ${test_gif} ${test_red}


# 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' ' '