about summary refs log tree commit diff
path: root/test/ps-flate-roundtrip.test
blob: 9fc24ddbdcf1c4d77b7b1f7b14a5068ad5963bb6 (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
#! /bin/sh
# This script tests: pnmtops pstopnm
# Also requires: pamtopnm gs zlib

# This script tests the optional flate (zlib) compression feature of
# pstopnm.
# Flate compression allows you to make smaller output (.ps) files:
# it is useful, but not essential.  Flate compression is not necessary for
# printing pages with postscript printers - which is why many people need
# pnmtops on their systems.

# Failure message
## This test fails when ghostscript is not available.

tmpdir=${tmpdir:-/tmp}

# pstopnm does not use libnetpbm functions for output.
# Output is filtered through pamtopnm.

echo "Test 1.  Should print: 1926073387 101484 twice"
test1_ps=${tmpdir}/testimg1.ps

for flag in "-ps -flate" "-ps -rle -ascii -flate"
  do
  pnmtops -nocenter -equalpixels -dpi 72 -noturn ${flag} testimg.ppm \
    > ${test1_ps} && \
  xysize1=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \
    ${test1_ps}` && \
  pstopnm -portrait -xborder=0 -yborder=0 $xysize1 -stdout -quiet \
    ${test1_ps} | pamtopnm | cksum
  done

rm ${test1_ps}

echo "Test 2. Should print 1831481505 608904"
# See comments in ps-roundtrip.test

test3_ps=${tmpdir}/testimg3.ps
flag="-ps -bitspersample=12 -flate -rle -vmreclaim"
cat testimg.ppm testimg.ppm testimg.ppm maze.pbm \
  testgrid.pbm testgrid.pbm | \
  pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage ${flag} \
    > ${test3_ps} &&
xysize3=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5 ; exit}' \
    ${test3_ps}` &&
pstopnm -portrait -xborder=0 -yborder=0 $xysize3 -stdout  ${test3_ps} | \
  pamtopnm | cksum

rm ${test3_ps}