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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
#!/bin/sh
# this has now been mostly superseded by test_foreign.py ... keep this around
# as a test of the command-line interface
# set -x
set -e
. ./variables.sh
# poppler / pdfload reference image
poppler=$test_images/blankpage.pdf
poppler_ref=$test_images/blankpage.pdf.png
# giflib / gifload reference image
giflib=$test_images/trans-x.gif
giflib_ref=$test_images/trans-x.png
# the matlab image and reference image
matlab=$test_images/sample.mat
matlab_ref=$test_images/sample.png
# make a mono image
$vips extract_band $image $tmp/mono.v 1
mono=$tmp/mono.v
# make a radiance image
$vips float2rad $image $tmp/rad.v
rad=$tmp/rad.v
# make a cmyk image
$vips bandjoin "$image $tmp/mono.v" $tmp/t1.v
$vips copy $tmp/t1.v $tmp/cmyk.v --interpretation cmyk
cmyk=$tmp/cmyk.v
# save to t1.format, load as back.v
save_load() {
in=$1
format=$2
mode=$3
if ! $vips copy $in $tmp/t1.$format$mode ; then
echo "write to $out failed"
exit 1
fi
if ! $vips copy $tmp/t1.$format $tmp/back.v ; then
echo "read from $tmp/t1.format failed"
echo " (was written by $vips copy $in $tmp/t1.$format$mode)"
exit 1
fi
}
# save to the named file in tmp, convert back to vips again, subtract, look
# for max difference less than a threshold
test_format() {
in=$1
format=$2
threshold=$3
mode=$4
printf "testing $(basename $in) $format$mode ... "
save_load $in $format $mode
test_difference $in $tmp/back.v $threshold
echo "ok"
}
# as above, but raw format
# we can't use suffix stuff to pick the load/save
test_raw() {
in=$1
printf "testing $(basename $in) raw ... "
$vips copy $in $tmp/before.v
width=$($vipsheader -f width $tmp/before.v)
height=$($vipsheader -f height $tmp/before.v)
bands=$($vipsheader -f bands $tmp/before.v)
$vips rawsave $tmp/before.v $tmp/raw
$vips rawload $tmp/raw $tmp/after.v $width $height $bands
test_difference $tmp/before.v $tmp/after.v 0
echo "ok"
}
# a format for which we only have a load (eg. matlab)
# pass in a reference file as well and compare to that
test_loader() {
ref=$1
in=$2
format=$3
thresh=$4
printf "testing $(basename $in) $format ... "
$vips copy $ref $tmp/before.v
$vips copy $in $tmp/after.v
test_difference $tmp/before.v $tmp/after.v $thresh
echo "ok"
}
# a format for which we only have a saver (eg. dzsave)
# just run the operation and check exit status
test_saver() {
oper=$1
in=$2
suffix=$3
printf "testing $oper $(basename $in) $suffix ... "
rm -rf $tmp/savertest*
cmd="$vips $oper $in $tmp/savertest$suffix"
if ! $cmd ; then
echo "error executing:"
echo " $cmd"
exit 1
fi
echo "ok"
}
test_format $image v 0
if test_supported tiffload; then
test_format $image tif 0
test_format $image tif 90 [compression=jpeg]
test_format $image tif 0 [compression=deflate]
test_format $image tif 0 [compression=packbits]
test_format $image tif 90 [compression=jpeg,tile]
test_format $image tif 90 [compression=jpeg,tile,pyramid]
fi
if test_supported pngload; then
test_format $image png 0
test_format $image png 0 [compression=9,interlace=1]
test_format $image png 90 [palette,colours=256,Q=100,dither=0,interlace=1]
fi
if test_supported jpegload; then
test_format $image jpg 90
fi
if test_supported webpload; then
test_format $image webp 90
fi
test_format $image ppm 0
test_format $image pfm 0
if test_supported fitsload; then
test_format $image fits 0
fi
# csv can only do mono
test_format $mono csv 0
test_format $rad hdr 0
# cmyk jpg is a special path
if test_supported jpegload; then
test_format $cmyk jpg 90
fi
if test_supported tiffload; then
test_format $cmyk tif 0
test_format $cmyk tif 90 [compression=jpeg]
test_format $cmyk tif 90 [compression=jpeg,tile]
test_format $cmyk tif 90 [compression=jpeg,tile,pyramid]
fi
test_raw $mono
test_raw $image
if test_supported pdfload; then
test_loader $poppler_ref $poppler pdfload 0
fi
# don't test SVG --- the output varies too much between librsvg versions
if test_supported gifload; then
test_loader $giflib_ref $giflib gifload 0
fi
if test_supported matload; then
test_loader $matlab_ref $matlab matlab 0
# test blocked and untrusted
printf "testing VIPS_BLOCK_UNTRUSTED with matio ... "
export VIPS_BLOCK_UNTRUSTED=1
if $vips matload $matlab $tmp/block.png; then
echo "failed to block matload"
exit 1
fi
echo "ok"
unset VIPS_BLOCK_UNTRUSTED
fi
if test_supported dzsave; then
test_saver dzsave $image .zip
test_saver copy $image .dz
test_saver copy $image .dz[container=zip]
fi
if test_supported jp2kload; then
test_format $image jp2 20
test_format $image jp2 0 [lossless]
fi
|