1#!/bin/bash 2 3set -u 4set -e 5trap onexit INT 6trap onexit TERM 7trap onexit EXIT 8 9onexit() 10{ 11 if [ -d $OUTDIR ]; then 12 rm -rf $OUTDIR 13 fi 14} 15 16runme() 17{ 18 echo \*\*\* $* 19 $* 20} 21 22IMAGE=vgl_6548_0026a.bmp 23WIDTH=128 24HEIGHT=95 25IMGDIR=@CMAKE_CURRENT_SOURCE_DIR@/testimages 26OUTDIR=`mktemp -d /tmp/__croptest_output.XXXXXX` 27EXEDIR=@CMAKE_CURRENT_BINARY_DIR@ 28 29if [ -d $OUTDIR ]; then 30 rm -rf $OUTDIR 31fi 32mkdir -p $OUTDIR 33 34exec >$EXEDIR/croptest.log 35 36echo "============================================================" 37echo "$IMAGE ($WIDTH x $HEIGHT)" 38echo "============================================================" 39echo 40 41for PROGARG in "" -progressive; do 42 43 cp $IMGDIR/$IMAGE $OUTDIR 44 basename=`basename $IMAGE .bmp` 45 echo "------------------------------------------------------------" 46 echo "Generating test images" 47 echo "------------------------------------------------------------" 48 echo 49 runme $EXEDIR/cjpeg $PROGARG -grayscale -outfile $OUTDIR/${basename}_GRAY.jpg $IMGDIR/${basename}.bmp 50 runme $EXEDIR/cjpeg $PROGARG -sample 2x2 -outfile $OUTDIR/${basename}_420.jpg $IMGDIR/${basename}.bmp 51 runme $EXEDIR/cjpeg $PROGARG -sample 2x1 -outfile $OUTDIR/${basename}_422.jpg $IMGDIR/${basename}.bmp 52 runme $EXEDIR/cjpeg $PROGARG -sample 1x2 -outfile $OUTDIR/${basename}_440.jpg $IMGDIR/${basename}.bmp 53 runme $EXEDIR/cjpeg $PROGARG -sample 1x1 -outfile $OUTDIR/${basename}_444.jpg $IMGDIR/${basename}.bmp 54 echo 55 56 for NSARG in "" -nosmooth; do 57 58 for COLORSARG in "" "-colors 256 -dither none -onepass"; do 59 60 for Y in {0..16}; do 61 62 for H in {1..16}; do 63 64 X=$(( (Y*16)%128 )) 65 W=$(( WIDTH-X-7 )) 66 if [ $Y -le 15 ]; then 67 CROPSPEC="${W}x${H}+${X}+${Y}" 68 else 69 Y2=$(( HEIGHT-H )); 70 CROPSPEC="${W}x${H}+${X}+${Y2}" 71 fi 72 73 echo "------------------------------------------------------------" 74 echo $PROGARG $NSARG $COLORSARG -crop $CROPSPEC 75 echo "------------------------------------------------------------" 76 echo 77 for samp in GRAY 420 422 440 444; do 78 $EXEDIR/djpeg $NSARG $COLORSARG -rgb -outfile $OUTDIR/${basename}_${samp}_full.ppm $OUTDIR/${basename}_${samp}.jpg 79 convert -crop $CROPSPEC $OUTDIR/${basename}_${samp}_full.ppm $OUTDIR/${basename}_${samp}_ref.ppm 80 runme $EXEDIR/djpeg $NSARG $COLORSARG -crop $CROPSPEC -rgb -outfile $OUTDIR/${basename}_${samp}.ppm $OUTDIR/${basename}_${samp}.jpg 81 runme cmp $OUTDIR/${basename}_${samp}.ppm $OUTDIR/${basename}_${samp}_ref.ppm 82 done 83 echo 84 85 done 86 87 done 88 89 done 90 91 done 92 93done 94 95echo SUCCESS! 96