From f1c8959e66046a42de580b2cece79a54eb982a67 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 4 Oct 2020 16:14:13 +0100 Subject: [PATCH] add a test for vipsthumbnail of stdin/stdout --- test/test_cli.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/test/test_cli.sh b/test/test_cli.sh index 633445af..f8c6a0ea 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -68,15 +68,13 @@ for i in nearest bicubic bilinear nohalo lbb; do test_rotate $image $i done -test_thumbnail() { - geo=$1 +test_size() { + to_test=$1 correct_width=$2 correct_height=$3 - printf "testing thumbnail -s $geo ... " - $vipsthumbnail $image -s "$geo" -o $tmp/t1.jpg - width=$($vipsheader -f width $tmp/t1.jpg) - height=$($vipsheader -f height $tmp/t1.jpg) + width=$($vipsheader -f width $to_test) + height=$($vipsheader -f height $to_test) if [ $width -ne $correct_width ]; then echo width is $width, not $correct_width exit 1 @@ -85,6 +83,16 @@ test_thumbnail() { echo height is $height, not $correct_height exit 1 fi +} + +test_thumbnail() { + geo=$1 + correct_width=$2 + correct_height=$3 + + printf "testing thumbnail -s $geo ... " + $vipsthumbnail $image -s "$geo" -o $tmp/t1.jpg + test_size $tmp/t1.jpg $correct_width $correct_height echo "ok" } @@ -96,3 +104,15 @@ test_thumbnail "100x100<" 290 442 test_thumbnail "2000<" 1312 2000 test_thumbnail "100x100>" 66 100 test_thumbnail "2000>" 290 442 + +# test thumbnail to and from pipes +echo -n "testing thumbnail of stdin / stdout ... " +$vipsthumbnail stdin -s 100 -o $tmp/t1.jpg < $image +test_size $tmp/t1.jpg 66 100 +cat $image | $vipsthumbnail stdin -s 100 -o $tmp/t1.jpg +test_size $tmp/t1.jpg 66 100 +cat $image | $vipsthumbnail stdin -s 100 -o .jpg > $tmp/t1.jpg +test_size $tmp/t1.jpg 66 100 +cat $image | $vipsthumbnail stdin -s 100 -o .jpg | cat > $tmp/t1.jpg +echo ok +test_size $tmp/t1.jpg 66 100