croptest.in 2.5 KB

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