2014-11-19 16:01:28 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-05-29 19:58:24 +02:00
|
|
|
# this has now been mostly superseded by test_foreign.py ... keep this around
|
2015-02-16 17:03:39 +01:00
|
|
|
# as a test of the command-line interface
|
|
|
|
|
2014-11-19 16:01:28 +01:00
|
|
|
# set -x
|
2016-06-02 20:38:41 +02:00
|
|
|
set -e
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
. ./variables.sh
|
|
|
|
|
2016-05-08 22:39:08 +02:00
|
|
|
# poppler / pdfload reference image
|
|
|
|
poppler=$test_images/blankpage.pdf
|
2017-07-08 16:09:35 +02:00
|
|
|
poppler_ref=$test_images/blankpage.pdf.png
|
2016-05-08 22:39:08 +02:00
|
|
|
|
2016-05-27 01:25:35 +02:00
|
|
|
# giflib / gifload reference image
|
|
|
|
giflib=$test_images/trans-x.gif
|
|
|
|
giflib_ref=$test_images/trans-x.png
|
|
|
|
|
2014-11-19 16:01:28 +01:00
|
|
|
# the matlab image and reference image
|
|
|
|
matlab=$test_images/sample.mat
|
|
|
|
matlab_ref=$test_images/sample.png
|
|
|
|
|
|
|
|
# make a mono image
|
2014-12-20 18:12:12 +01:00
|
|
|
$vips extract_band $image $tmp/mono.v 1
|
2014-11-19 16:01:28 +01:00
|
|
|
mono=$tmp/mono.v
|
|
|
|
|
|
|
|
# make a radiance image
|
2014-12-20 18:12:12 +01:00
|
|
|
$vips float2rad $image $tmp/rad.v
|
2014-11-19 16:01:28 +01:00
|
|
|
rad=$tmp/rad.v
|
|
|
|
|
|
|
|
# make a cmyk image
|
2014-12-20 18:12:12 +01:00
|
|
|
$vips bandjoin "$image $tmp/mono.v" $tmp/t1.v
|
|
|
|
$vips copy $tmp/t1.v $tmp/cmyk.v --interpretation cmyk
|
2014-11-19 16:01:28 +01:00
|
|
|
cmyk=$tmp/cmyk.v
|
|
|
|
|
|
|
|
# save to t1.format, load as back.v
|
|
|
|
save_load() {
|
|
|
|
in=$1
|
|
|
|
format=$2
|
|
|
|
mode=$3
|
|
|
|
|
2014-12-20 18:12:12 +01:00
|
|
|
if ! $vips copy $in $tmp/t1.$format$mode ; then
|
2014-11-19 16:01:28 +01:00
|
|
|
echo "write to $out failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-12-20 18:12:12 +01:00
|
|
|
if ! $vips copy $tmp/t1.$format $tmp/back.v ; then
|
2016-11-08 15:42:54 +01:00
|
|
|
echo "read from $tmp/t1.format failed"
|
|
|
|
echo " (was written by $vips copy $in $tmp/t1.$format$mode)"
|
2014-11-19 16:01:28 +01:00
|
|
|
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
|
|
|
|
|
2014-12-20 17:17:44 +01:00
|
|
|
printf "testing $(basename $in) $format$mode ... "
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
save_load $in $format $mode
|
|
|
|
test_difference $in $tmp/back.v $threshold
|
|
|
|
|
|
|
|
echo "ok"
|
|
|
|
}
|
|
|
|
|
|
|
|
# as above, but hdr format
|
|
|
|
# this is a coded format, so we need to rad2float before we can test for
|
|
|
|
# differences
|
|
|
|
test_rad() {
|
|
|
|
in=$1
|
|
|
|
|
2014-12-20 17:17:44 +01:00
|
|
|
printf "testing $(basename $in) hdr ... "
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
save_load $in hdr
|
|
|
|
|
2014-12-20 18:12:12 +01:00
|
|
|
$vips rad2float $in $tmp/before.v
|
|
|
|
$vips rad2float $tmp/back.v $tmp/after.v
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
test_difference $tmp/before.v $tmp/after.v 0
|
|
|
|
|
|
|
|
echo "ok"
|
|
|
|
}
|
|
|
|
|
|
|
|
# as above, but raw format
|
|
|
|
# we can't use suffix stuff to pick the load/save
|
|
|
|
test_raw() {
|
|
|
|
in=$1
|
|
|
|
|
2014-12-20 17:17:44 +01:00
|
|
|
printf "testing $(basename $in) raw ... "
|
2014-11-19 16:01:28 +01:00
|
|
|
|
2014-12-20 18:12:12 +01:00
|
|
|
$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)
|
2014-11-19 16:01:28 +01:00
|
|
|
|
2014-12-20 18:12:12 +01:00
|
|
|
$vips rawsave $tmp/before.v $tmp/raw
|
|
|
|
$vips rawload $tmp/raw $tmp/after.v $width $height $bands
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
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
|
2017-07-08 16:26:48 +02:00
|
|
|
thresh=$4
|
2014-11-19 16:01:28 +01:00
|
|
|
|
2014-12-20 17:17:44 +01:00
|
|
|
printf "testing $(basename $in) $format ... "
|
2014-11-19 16:01:28 +01:00
|
|
|
|
2014-12-20 18:12:12 +01:00
|
|
|
$vips copy $ref $tmp/before.v
|
|
|
|
$vips copy $in $tmp/after.v
|
2014-11-19 16:01:28 +01:00
|
|
|
|
2017-07-08 16:26:48 +02:00
|
|
|
test_difference $tmp/before.v $tmp/after.v $thresh
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
echo "ok"
|
|
|
|
}
|
|
|
|
|
2015-02-13 12:17:55 +01:00
|
|
|
# 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"
|
|
|
|
}
|
|
|
|
|
2014-11-19 16:01:28 +01:00
|
|
|
test_format $image v 0
|
2014-12-22 11:35:26 +01:00
|
|
|
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
|
2018-06-18 02:22:46 +02:00
|
|
|
test_format $image png 0 [compression=9,interlace=1]
|
2018-06-19 22:41:40 +02:00
|
|
|
test_format $image png 90 [palette,colours=256,Q=100,dither=0,interlace=1]
|
2014-12-22 11:35:26 +01:00
|
|
|
fi
|
|
|
|
if test_supported jpegload; then
|
|
|
|
test_format $image jpg 90
|
|
|
|
fi
|
2016-04-23 23:36:49 +02:00
|
|
|
if test_supported webpload; then
|
|
|
|
test_format $image webp 90
|
|
|
|
fi
|
2014-11-19 16:01:28 +01:00
|
|
|
test_format $image ppm 0
|
|
|
|
test_format $image pfm 0
|
2014-12-22 11:35:26 +01:00
|
|
|
if test_supported fitsload; then
|
|
|
|
test_format $image fits 0
|
|
|
|
fi
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
# csv can only do mono
|
|
|
|
test_format $mono csv 0
|
|
|
|
|
|
|
|
# cmyk jpg is a special path
|
2014-12-22 11:35:26 +01:00
|
|
|
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
|
2014-11-19 16:01:28 +01:00
|
|
|
|
|
|
|
test_rad $rad
|
|
|
|
|
|
|
|
test_raw $mono
|
|
|
|
test_raw $image
|
|
|
|
|
2016-05-08 22:39:08 +02:00
|
|
|
if test_supported pdfload; then
|
2017-07-08 16:26:48 +02:00
|
|
|
test_loader $poppler_ref $poppler pdfload 0
|
2016-05-08 22:39:08 +02:00
|
|
|
fi
|
|
|
|
|
2019-09-17 17:26:23 +02:00
|
|
|
# don't test SVG --- the output varies too much between librsvg versions
|
2016-05-27 00:57:45 +02:00
|
|
|
|
2016-05-27 01:25:35 +02:00
|
|
|
if test_supported gifload; then
|
2017-07-08 16:26:48 +02:00
|
|
|
test_loader $giflib_ref $giflib gifload 0
|
2016-05-27 01:25:35 +02:00
|
|
|
fi
|
|
|
|
|
2014-12-22 11:35:26 +01:00
|
|
|
if test_supported matload; then
|
2017-07-08 16:26:48 +02:00
|
|
|
test_loader $matlab_ref $matlab matlab 0
|
2022-06-12 13:24:30 +02:00
|
|
|
|
|
|
|
# test blocked and untrusted
|
|
|
|
printf "testing VIPS_BLOCK_UNTRUSTED with matio ... "
|
|
|
|
export VIPS_BLOCK_UNTRUSTED=1
|
2022-08-02 14:50:09 +02:00
|
|
|
if $vips matload $matlab $tmp/block.png; then
|
2022-06-12 13:24:30 +02:00
|
|
|
echo "failed to block matload"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "ok"
|
|
|
|
unset VIPS_BLOCK_UNTRUSTED
|
2014-12-22 11:35:26 +01:00
|
|
|
fi
|
2014-11-19 16:01:28 +01:00
|
|
|
|
2015-02-13 12:17:55 +01:00
|
|
|
if test_supported dzsave; then
|
|
|
|
test_saver dzsave $image .zip
|
|
|
|
test_saver copy $image .dz
|
|
|
|
test_saver copy $image .dz[container=zip]
|
|
|
|
fi
|
2022-06-23 11:03:29 +02:00
|
|
|
|
|
|
|
if test_supported jp2kload; then
|
|
|
|
test_format $image jp2 20
|
|
|
|
test_format $image jp2 0 [lossless]
|
|
|
|
fi
|